[U-Boot] [PATCH 5/6] at91: add function to set IO drive

Andreas Bießmann andreas at biessmann.org
Fri Oct 7 00:11:13 CEST 2016


On 17.08.16 09:13, Heiko Schocher wrote:
> add new function to set I/O drive.
> 
> Signed-off-by: Heiko Schocher <hs at denx.de>
> ---
> 
>  arch/arm/mach-at91/include/mach/at91_pio.h |  5 +++++
>  arch/arm/mach-at91/include/mach/gpio.h     |  2 ++
>  drivers/gpio/at91_gpio.c                   | 29 +++++++++++++++++++++++++++++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach-at91/include/mach/at91_pio.h
> index 8e054e1..535208a 100644
> --- a/arch/arm/mach-at91/include/mach/at91_pio.h
> +++ b/arch/arm/mach-at91/include/mach/at91_pio.h
> @@ -134,6 +134,7 @@ int at91_set_pio_debounce(unsigned port, unsigned pin, int is_on, int div);
>  int at91_set_pio_pulldown(unsigned port, unsigned pin, int is_on);
>  int at91_set_pio_disable_schmitt_trig(unsigned port, unsigned pin);
>  #endif
> +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value);
>  int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup);
>  int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on);
>  int at91_set_pio_output(unsigned port, unsigned pin, int value);
> @@ -151,4 +152,8 @@ int at91_get_pio_value(unsigned port, unsigned pin);
>  #define	AT91_PIO_PORTD		0x3
>  #define	AT91_PIO_PORTE		0x4
>  
> +/* allowed I/O driver values */
> +#define AT91_PIO_HI_DRIVE	0

sama5 has 0 + 1 low drive, 2 medium and 3 hi :(

> +#define AT91_PIO_MEDIUM_DRIVE	1
> +#define AT91_PIO_LOW_DRIVE	2
>  #endif
> diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h
> index 6d2a7b7..2b89309 100644
> --- a/arch/arm/mach-at91/include/mach/gpio.h
> +++ b/arch/arm/mach-at91/include/mach/gpio.h
> @@ -227,6 +227,8 @@ static inline unsigned pin_to_mask(unsigned pin)
>  	at91_set_pio_value((x - PIN_BASE) / 32,(x % 32), y)
>  #define at91_get_gpio_value(x) \
>  	at91_get_pio_value((x - PIN_BASE) / 32,(x % 32))
> +#define at91_set_gpio_io_drive(x, v) \
> +	at91_set_pio_io_drive((x - PIN_BASE) / 32,(x % 32), v)
>  #else
>  #define at91_set_gpio_value(x, y)	at91_set_pio_value(x, y)
>  #define at91_get_gpio_value(x)		at91_get_pio_value(x)
> diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
> index 8e52e3d..1f624f8 100644
> --- a/drivers/gpio/at91_gpio.c
> +++ b/drivers/gpio/at91_gpio.c
> @@ -358,6 +358,35 @@ int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on)
>  	return 0;
>  }
>  
> +#if defined(CPU_HAS_PIO3)
> +/*
> + * set I/O driver value
> + */
> +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value)
> +{
> +	struct at91_port *at91_port = at91_pio_get_port(port);
> +	u32 *reg;
> +	u32 mask;
> +
> +	if (pin > 15) {
> +		reg = &at91_port->io_driver2;
> +		pin -= 16;
> +	} else {
> +		reg = &at91_port->io_driver1;
> +	}
> +
> +	mask = 0x3 << (pin * 2);
> +	clrsetbits_le32(reg, mask, value << (pin * 2));
> +	return 0;
> +}
> +#else
> +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value)
> +{
> +	return -ENOENT;
> +}
> +#endif
> +
> +
>  static void at91_set_port_value(struct at91_port *at91_port, int offset,
>  				int value)
>  {
> 


More information about the U-Boot mailing list