From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Date: Sun, 28 Mar 2010 12:35:14 -0500 Subject: [U-Boot] [PATCH 3/8] nomadik_gpio: get base address from platform code In-Reply-To: <1268888542-29586-1-git-send-email-rabin.vincent@stericsson.com> References: <1268886061-6382-1-git-send-email-rabin.vincent@stericsson.com> <1268888542-29586-1-git-send-email-rabin.vincent@stericsson.com> Message-ID: <4BAF9352.6000407@windriver.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > Acked-by: Michael Brandt > Signed-off-by: Rabin Vincent > --- > 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 > #include > > -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