public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 1/4] arm, imx6: add mxc_iomux_set_gpr_register function
Date: Fri, 11 Jul 2014 13:10:13 +0200	[thread overview]
Message-ID: <53BFC615.6000102@denx.de> (raw)
In-Reply-To: <1401272177-16107-2-git-send-email-hs@denx.de>

Hi Heiko,

On 28/05/2014 12:16, Heiko Schocher wrote:
> add mxc_iomux_set_gpr_register fucntion
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
>  arch/arm/imx-common/iomux-v3.c             | 15 +++++++++++++++
>  arch/arm/include/asm/imx-common/iomux-v3.h |  2 ++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/arch/arm/imx-common/iomux-v3.c b/arch/arm/imx-common/iomux-v3.c
> index 6e46ea8..8739b4c 100644
> --- a/arch/arm/imx-common/iomux-v3.c
> +++ b/arch/arm/imx-common/iomux-v3.c
> @@ -63,3 +63,18 @@ void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
>  	for (i = 0; i < count; i++)
>  		imx_iomux_v3_setup_pad(*p++);
>  }
> +
> +void mxc_iomux_set_gpr_register(int group, int start_bit, int num_bits,
> +				int value)
> +{
> +	int i = 0;
> +	u32 reg;
> +	reg = __raw_readl(base + group * 4);
> +	while (num_bits) {
> +		reg &= ~(1<<(start_bit + i));
> +		i++;
> +		num_bits--;
> +	}
> +	reg |= (value << start_bit);
> +	__raw_writel(reg, base + group * 4);
> +}

It is not clear to me why we need to add this or better, I want to avoid
having twice quite the same code doing the same ;-).

We have already a field for gpr:
struct iomuxc {
        u32 gpr[14];
        u32 omux[5];
        /* mux and pad registers */
};

+	reg = __raw_readl(base + group * 4);

this could not work when Freescale introduce a new variant with a slight
different layout. Thanks to Fabio, we know this is already reality:

	http://patchwork.ozlabs.org/patch/368336/

Your code *does* not work with the solox.

Generally, we access register and we use setbits_ and clrsetbits_ to
modify single bits. What is the advantage here ?

> diff --git a/arch/arm/include/asm/imx-common/iomux-v3.h b/arch/arm/include/asm/imx-common/iomux-v3.h
> index cca920b..4c83617 100644
> --- a/arch/arm/include/asm/imx-common/iomux-v3.h
> +++ b/arch/arm/include/asm/imx-common/iomux-v3.h
> @@ -174,5 +174,7 @@ typedef u64 iomux_v3_cfg_t;
>  void imx_iomux_v3_setup_pad(iomux_v3_cfg_t pad);
>  void imx_iomux_v3_setup_multiple_pads(iomux_v3_cfg_t const *pad_list,
>  				     unsigned count);
> +void mxc_iomux_set_gpr_register(int group, int start_bit, int num_bits,
> +				int value);
>  
>  #endif	/* __MACH_IOMUX_V3_H__*/
> 

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

  reply	other threads:[~2014-07-11 11:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-28 10:16 [U-Boot] [PATCH v1 0/4] arm, imx6: add aristainetos board support Heiko Schocher
2014-05-28 10:16 ` [U-Boot] [PATCH v1 1/4] arm, imx6: add mxc_iomux_set_gpr_register function Heiko Schocher
2014-07-11 11:10   ` Stefano Babic [this message]
2014-07-11 13:00     ` Heiko Schocher
2014-05-28 10:16 ` [U-Boot] [PATCH v1 2/4] spi, spi_mxc: do not hang in spi_xchg_single Heiko Schocher
2014-05-28 11:09   ` Jagan Teki
2014-05-29  5:12   ` Dirk Behme
2014-05-29  5:22     ` Heiko Schocher
2014-05-28 10:16 ` [U-Boot] [PATCH v1 3/4] i.MX6: add enable_spi_clk() Heiko Schocher
2014-07-11 11:14   ` Stefano Babic
2014-07-11 13:22   ` Fabio Estevam
2014-07-15  8:15     ` Stefano Babic
2014-05-28 10:16 ` [U-Boot] [PATCH v1 4/4] arm, imx6: add aristainetos board Heiko Schocher
2014-07-11 12:26   ` Stefano Babic
2014-07-11 14:12     ` 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=53BFC615.6000102@denx.de \
    --to=sbabic@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox