[U-Boot] [PATCH 1/2] gpio: add gpio api support to mx27 (v2)

Stefano Babic sbabic at denx.de
Thu Aug 23 16:39:52 CEST 2012


On 06/08/2012 17:29, Philippe Reynes wrote:
> There is a little change on gpio_get_value because
> on mx27 the register to read is ssr and not dr.
> 
> Signed-off-by: Philippe Reynes <tremyfr at yahoo.fr>
> ---

Hi Philippe,

>  arch/arm/cpu/arm926ejs/mx27/generic.c     |   11 +++---
>  arch/arm/include/asm/arch-mx27/gpio.h     |   55 +++++++++++++++++++++++++++++
>  arch/arm/include/asm/arch-mx27/imx-regs.h |   30 ++++------------
>  drivers/gpio/mxc_gpio.c                   |   12 +++++--
>  4 files changed, 77 insertions(+), 31 deletions(-)
>  create mode 100644 arch/arm/include/asm/arch-mx27/gpio.h
> 
> diff --git a/arch/arm/cpu/arm926ejs/mx27/generic.c b/arch/arm/cpu/arm926ejs/mx27/generic.c
> index 65c4813..41bb84b 100644
> --- a/arch/arm/cpu/arm926ejs/mx27/generic.c
> +++ b/arch/arm/cpu/arm926ejs/mx27/generic.c
> @@ -24,6 +24,7 @@
>  #include <asm/io.h>
>  #include <asm/arch/imx-regs.h>
>  #include <asm/arch/clock.h>
> +#include <asm/arch/gpio.h>
>  #ifdef CONFIG_MXC_MMC
>  #include <asm/arch/mxcmmc.h>
>  #endif
> @@ -209,7 +210,7 @@ int cpu_mmc_init(bd_t *bis)
>  
>  void imx_gpio_mode(int gpio_mode)
>  {
> -	struct gpio_regs *regs = (struct gpio_regs *)IMX_GPIO_BASE;
> +	struct gpio_port_regs *regs = (struct gpio_port_regs *)IMX_GPIO_BASE;
>  	unsigned int pin = gpio_mode & GPIO_PIN_MASK;
>  	unsigned int port = (gpio_mode & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
>  	unsigned int ocr = (gpio_mode & GPIO_OCR_MASK) >> GPIO_OCR_SHIFT;
> @@ -228,11 +229,11 @@ void imx_gpio_mode(int gpio_mode)
>  
>  	/* Data direction */
>  	if (gpio_mode & GPIO_OUT) {
> -		writel(readl(&regs->port[port].ddir) | 1 << pin,
> -				&regs->port[port].ddir);
> +		writel(readl(&regs->port[port].gpio_dir) | 1 << pin,
> +				&regs->port[port].gpio_dir);
>  	} else {
> -		writel(readl(&regs->port[port].ddir) & ~(1 << pin),
> -				&regs->port[port].ddir);
> +		writel(readl(&regs->port[port].gpio_dir) & ~(1 << pin),
> +				&regs->port[port].gpio_dir);
>  	}

This is strange, because it does not make use of
gpio_direction_output(). However, if we use it, generic.c depends on
CONFIG_MXC_GPIO. Ok


>  
> +#ifndef CONFIG_MX27
>  	val = (readl(&regs->gpio_dr) >> gpio) & 0x01;
> +#else
> +	val = (readl(&regs->ssr) >> gpio) & 0x01;
> +#endif
>  

A recent patch uses psr on the other SOC instead of dr to read directly
the pad status instead of the internal shadow register. If you rename
your ssr into gpio_psr we do not need this #ifdef.

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


More information about the U-Boot mailing list