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 1/2] mx5: Add default pin initializers
Date: Fri, 17 Aug 2012 22:25:16 +0200	[thread overview]
Message-ID: <502EA8AC.4020105@denx.de> (raw)
In-Reply-To: <883852451.2404814.1344959214390.JavaMail.root@advansee.com>

On 14/08/2012 17:46, Beno?t Th?baudeau wrote:
> Create default pin initialization functions for the default iomux function
> assignments of the main peripherals.
> 
> Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com>
> Cc: Stefano Babic <sbabic@denx.de>
> ---

Hi Beno?t,

>  .../arch/arm/cpu/armv7/mx5/soc.c                   |  139 ++++++++++++++++++++
>  .../arch/arm/include/asm/arch-mx5/sys_proto.h      |    5 +
>  2 files changed, 144 insertions(+)
> 
> diff --git u-boot-4d3c95f.orig/arch/arm/cpu/armv7/mx5/soc.c u-boot-4d3c95f/arch/arm/cpu/armv7/mx5/soc.c
> index 3f5a4f7..ee19b54 100644
> --- u-boot-4d3c95f.orig/arch/arm/cpu/armv7/mx5/soc.c
> +++ u-boot-4d3c95f/arch/arm/cpu/armv7/mx5/soc.c
> @@ -25,6 +25,8 @@
>  
>  #include <common.h>
>  #include <asm/arch/imx-regs.h>
> +#include <asm/arch/mx5x_pins.h>
> +#include <asm/arch/iomux.h>
>  #include <asm/arch/clock.h>
>  #include <asm/arch/sys_proto.h>
>  
> @@ -71,6 +73,143 @@ u32 get_cpu_rev(void)
>  	return system_rev;
>  }
>  
> +#ifdef CONFIG_MXC_UART
> +#if CONFIG_MXC_UART_BASE == UART1_BASE
> +#ifdef CONFIG_MX51
> +void mx51_uart1_init_pins(void)
> +{
> +	int in_pad, out_pad;
> +
> +	/* Set up pins for UART1. */
> +	mxc_request_iomux(MX51_PIN_UART1_RXD, IOMUX_CONFIG_ALT0);
> +	mxc_request_iomux(MX51_PIN_UART1_TXD, IOMUX_CONFIG_ALT0);
> +	mxc_request_iomux(MX51_PIN_UART1_RTS, IOMUX_CONFIG_ALT0);
> +	mxc_request_iomux(MX51_PIN_UART1_CTS, IOMUX_CONFIG_ALT0);
> +
> +	mxc_iomux_set_input(MX51_UART1_IPP_UART_RXD_MUX_SELECT_INPUT,
> +			    INPUT_CTL_PATH0);
> +	mxc_iomux_set_input(MX51_UART1_IPP_UART_RTS_B_SELECT_INPUT,
> +			    INPUT_CTL_PATH0);
> +
> +	in_pad = PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE | PAD_CTL_PUE_PULL |
> +		PAD_CTL_100K_PU | PAD_CTL_ODE_OPENDRAIN_NONE |
> +		PAD_CTL_DRV_HIGH | PAD_CTL_SRE_SLOW;
> +	out_pad = PAD_CTL_HYS_NONE | PAD_CTL_PKE_NONE |
> +		PAD_CTL_ODE_OPENDRAIN_NONE | PAD_CTL_DRV_HIGH |
> +		PAD_CTL_SRE_SLOW;
> +
> +	mxc_iomux_set_pad(MX51_PIN_UART1_RXD, in_pad);
> +	mxc_iomux_set_pad(MX51_PIN_UART1_TXD, out_pad);
> +	mxc_iomux_set_pad(MX51_PIN_UART1_RTS, in_pad);
> +	mxc_iomux_set_pad(MX51_PIN_UART1_CTS, out_pad);
> +}

Yes, the intention is surely to rationalize code and to avoid
duplication. But it requires to add such kind of function for any
instance of a peripheral (mx51_uart2_init_pins, for example) and cannot
worked on all boards. For example, a board will not use RTS and CTS, and
these pins are GPIOs (very common example). Or it can use other pins for
RX and TXD: the SOC allows this, and maybe someone want to use it.

The other thing I see (not in this patch, but checking the current
implementation in mainline) is that we have different implementation for
MX51, MX53 / MX6. This is bad.

I think that setting each pin with mxc_request_iomux() is not a great
idea. Maybe another solution would be to provide a table with the pinmux
for the whole SOC and a funtion to set all of them, as
imx_iomux_v3_setup_multiple_pads. This is also similar to the current
implementation in u-boot for other SOCs, for example TI.

IMHO to improve the current situation in i.MX pinmux code we should try
to use the same code, or at least, the same API for the board
maintainer, and putting the pinmux configuration in a table. This is
also what the legacy kernel does, putting in the table only the pins
required by u-boot itself (current kernel sets itself the pinmux, via
device tree or initializing the board when dts is not available).

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

  parent reply	other threads:[~2012-08-17 20:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 15:46 [U-Boot] [PATCH 1/2] mx5: Add default pin initializers Benoît Thébaudeau
2012-08-14 15:47 ` [U-Boot] [PATCH 2/2] mx5: Use " Benoît Thébaudeau
2012-08-15 14:37   ` Benoît Thébaudeau
2012-08-16 19:46   ` Matt Sealey
2012-08-16 20:09     ` Benoît Thébaudeau
2012-08-16 21:25       ` Matt Sealey
2012-08-16 22:51         ` Benoît Thébaudeau
2012-08-17 18:53           ` Matt Sealey
2012-08-17 19:26             ` Benoît Thébaudeau
2012-08-17 21:08         ` Stefano Babic
2012-08-16 20:19     ` Marek Vasut
2012-08-17 19:10 ` [U-Boot] [PATCH 1/2] mx5: Add " Matt Sealey
2012-08-17 19:40   ` Benoît Thébaudeau
2012-08-17 20:25 ` Stefano Babic [this message]
2012-08-17 20:38   ` Matt Sealey

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=502EA8AC.4020105@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