[U-Boot] [PATCH 3/8] nomadik_gpio: get base address from platform code

Tom Tom.Rix at windriver.com
Sun Mar 28 19:35:14 CEST 2010


Rabin Vincent wrote:
> Change the Nomadik GPIO driver to get the base addresses from platform
> specific code, since it will be used on multiple platforms with
> different base addresses.
> 
> Acked-by: Alessandro Rubini <rubini at unipv.it>
> Acked-by: Michael Brandt <michael.brandt at stericsson.com>
> Signed-off-by: Rabin Vincent <rabin.vincent at stericsson.com>
> ---
>  board/st/nhk8815/nhk8815.c  |    7 +++++++
>  drivers/gpio/nomadik_gpio.c |    9 +--------
>  include/nomadik_gpio.h      |    2 ++
>  3 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/board/st/nhk8815/nhk8815.c b/board/st/nhk8815/nhk8815.c
> index 4f5f94f..79c91a7 100644
> --- a/board/st/nhk8815/nhk8815.c
> +++ b/board/st/nhk8815/nhk8815.c
> @@ -32,6 +32,13 @@
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> +unsigned long nmk_gpio_base[] = {
> +	NOMADIK_GPIO0_BASE,
> +	NOMADIK_GPIO1_BASE,
> +	NOMADIK_GPIO2_BASE,
> +	NOMADIK_GPIO3_BASE
> +};
> +

Should added #if-def CONFIG_NOMADIK_GPIO, to not include this global if
it is not used.

>  #ifdef CONFIG_SHOW_BOOT_PROGRESS
>  void show_boot_progress(int progress)
>  {
> diff --git a/drivers/gpio/nomadik_gpio.c b/drivers/gpio/nomadik_gpio.c
> index e8a7bca..deb2beb 100644
> --- a/drivers/gpio/nomadik_gpio.c
> +++ b/drivers/gpio/nomadik_gpio.c
> @@ -24,13 +24,6 @@
>  #include <asm/io.h>
>  #include <nomadik_gpio.h>
>  
> -static unsigned long gpio_base[4] = {
> -	NOMADIK_GPIO0_BASE,
> -	NOMADIK_GPIO1_BASE,
> -	NOMADIK_GPIO2_BASE,
> -	NOMADIK_GPIO3_BASE
> -};
> -
>  enum gpio_registers {
>  	GPIO_DAT =	0x00,		/* data register */
>  	GPIO_DATS =	0x04,		/* data set */
> @@ -45,7 +38,7 @@ enum gpio_registers {
>  
>  static inline unsigned long gpio_to_base(int gpio)
>  {
> -	return gpio_base[gpio / 32];
> +	return nmk_gpio_base[gpio / 32];

Should a check on the input.
(gpio / 32) < NMK_GPIO_BASE_INDEX_MAX

Add
#define NMK_GPIO_BASE_INDEX_MAX 4
Different values per board

Ok to change the name NMK_GPIO_BASE_INDEX_MAX
to something you like.

>  }
>  
>  static inline u32 gpio_to_bit(int gpio)
> diff --git a/include/nomadik_gpio.h b/include/nomadik_gpio.h
> index 1d3c9ce..2822db4 100644
> --- a/include/nomadik_gpio.h
> +++ b/include/nomadik_gpio.h
> @@ -34,6 +34,8 @@ enum nmk_af { /* alternate function settings */
>  	GPIO_ALT_C
>  };
>  
> +extern unsigned long nmk_gpio_base[];
> +
>  extern void nmk_gpio_af(int gpio, int alternate_function);
>  extern void nmk_gpio_dir(int gpio, int dir);
>  extern void nmk_gpio_set(int gpio, int val);


Tom


More information about the U-Boot mailing list