[U-Boot] [PATCH 2/9 v2] i.MX31: add a simple gpio driver
Anatolij Gustschin
agust at denx.de
Thu Feb 5 15:50:23 CET 2009
Hi Guennadi,
Guennadi Liakhovetski wrote:
> diff --git a/drivers/gpio/mx31_gpio.c b/drivers/gpio/mx31_gpio.c
> new file mode 100644
> index 0000000..6487e63
> --- /dev/null
> +++ b/drivers/gpio/mx31_gpio.c
<snip>
> +#include <common.h>
> +#include <asm/arch/mx31.h>
> +#include <asm/arch/mx31-regs.h>
> +
> +/* GPIO port description */
> +static unsigned long gpio_ports[] = {
> + [0] = 0x53fcc000,
> + [1] = 0x53fd0000,
> + [2] = 0x53fa4000,
> +};
Ilya send a patch for mx31 GPIO register definitions today
http://lists.denx.de/pipermail/u-boot/2009-February/046884.html
Could you please provide additional patch for drivers/gpio/mx31_gpio.c
based on Ilya's patch to use these GPIOx_BASE macros here and to
use GPIO_DR / GPIO_GDIR for 0 / 4 below? Thanks!
> +void mx31_gpio_set(unsigned int gpio, unsigned int value)
> +{
> + unsigned int port = gpio >> 5;
> + u32 l;
> +
> + if (port > sizeof(gpio_ports) / sizeof(gpio_ports[0]) - 1)
also please change this one to
if (port >= ARRAY_SIZE(gpio_ports))
too, to be consistent with coding in this file, Thanks!
> + return;
> +
> + gpio &= 0x1f;
> +
> + l = __REG(gpio_ports[port] + 0);
> + if (value)
> + l |= 1 << gpio;
> + else
> + l &= ~(1 << gpio);
> + __REG(gpio_ports[port] + 0) = l;
> +}
> diff --git a/include/asm-arm/arch-mx31/mx31.h b/include/asm-arm/arch-mx31/mx31.h
> index 0552c27..e957d72 100644
> --- a/include/asm-arm/arch-mx31/mx31.h
> +++ b/include/asm-arm/arch-mx31/mx31.h
> @@ -27,4 +27,24 @@
> extern u32 mx31_get_ipg_clk(void);
> extern void mx31_gpio_mux(unsigned long mode);
>
> +enum mx31_gpio_direction {
> + MX31_GPIO_DIRECTION_IN,
> + MX31_GPIO_DIRECTION_OUT,
> +};
> +
> +#ifdef CONFIG_MX31_GPIO
> +extern int mx31_gpio_direction(unsigned int gpio,
> + enum mx31_gpio_direction direction);
________________________^^^^^^^
please remove spaces here, Thanks!
> +extern void mx31_gpio_set(unsigned int gpio, unsigned int value);
> +#else
> +static inline int mx31_gpio_direction(unsigned int gpio,
> + enum mx31_gpio_direction direction)
________________________^^^^^^^
please remove spaces here too, Thanks!
Best regards,
Anatolij
More information about the U-Boot
mailing list