From patchwork Fri Jun 21 08:50:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 253162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E36752C02F7 for ; Fri, 21 Jun 2013 18:50:34 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 824354A235; Fri, 21 Jun 2013 10:50:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qbhxrhd3b3xM; Fri, 21 Jun 2013 10:50:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 938CB4A237; Fri, 21 Jun 2013 10:50:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 247E34A237 for ; Fri, 21 Jun 2013 10:50:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9sRVHe8olWcb for ; Fri, 21 Jun 2013 10:50:20 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42]) by theia.denx.de (Postfix) with ESMTPS id 130C74A235 for ; Fri, 21 Jun 2013 10:50:13 +0200 (CEST) Received: by mail-pb0-f42.google.com with SMTP id un1so7477390pbc.1 for ; Fri, 21 Jun 2013 01:50:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:mime-version:content-transfer-encoding :x-gm-message-state; bh=BmOLQMTZgUVybJDegqtPC9BZO2ukU9ilJGb8ld+NKHw=; b=USWao3OuPVXrRdcAjBYM+R6leUhKkfLavG3a7EoD9Q+j6Cy4nCh1vOJj3BCEAxP/Lt UqdYe3Uzbgn7JmLktaY77ePz9VMc238K9Uy1pRSfTypodza+YVeY3ygQrwk3ojxsMB5y L/YEKYuQYVUHiGjEWYz7SFW+feED7ZuxdCOHxlvj1ehFfMoR5knUyEmH8lD/POEUpUem whSLSipmmr97T0uMhZD+WVh+cLUKxINzCcX4yXNS0j1yyEmeLD2mU8jwTdKU/jWYaQVv 0su549e/DlB8x/mcnZqsvi1XRoJr/cTppkRT5r/TlZ6yppZbtQP6PNRKAJrg4mrxViZg Fpgg== X-Received: by 10.66.141.4 with SMTP id rk4mr15115945pab.127.1371804611769; Fri, 21 Jun 2013 01:50:11 -0700 (PDT) Received: from [192.168.0.100] (114-39-103-89.dynamic.hinet.net. [114.39.103.89]) by mx.google.com with ESMTPSA id vz8sm4763825pac.20.2013.06.21.01.50.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Jun 2013 01:50:11 -0700 (PDT) Message-ID: <1371804605.20409.2.camel@phoenix> From: Axel Lin To: Steve Sakoman Date: Fri, 21 Jun 2013 16:50:05 +0800 In-Reply-To: <1371804473.20409.0.camel@phoenix> References: <1371804473.20409.0.camel@phoenix> X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQnbkjv4nKvGf4RJZoJCSdOAnuYdrvNZ3sPaIrusV9XE17ClkwJXcSy4liZmSlBpVFQ97MeH Cc: Vasut , Marek@theia.denx.de, Schocher , u-boot@lists.denx.de, Tom Rini , Heiko@theia.denx.de, Stefan Roese Subject: [U-Boot] [PATCH 2/2] OMAP: gpio: Introduce get_omap_gpio_count() function to get gpio count X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Now the omap_gpio driver is used by AM33XX, OMAP3/4, OMAP54XX and DRA7XX SoCs. These SoCs have various gpio count. Thus introduce get_omap_gpio_count() function to get correct gpio count. Signed-off-by: Axel Lin --- arch/arm/cpu/armv7/am33xx/board.c | 5 +++++ arch/arm/cpu/armv7/omap3/board.c | 5 +++++ arch/arm/cpu/armv7/omap4/hwinit.c | 5 +++++ arch/arm/cpu/armv7/omap5/hwinit.c | 5 +++++ arch/arm/include/asm/omap_gpio.h | 1 + drivers/gpio/omap_gpio.c | 2 +- 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 885fb2d..405d649 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -51,6 +51,11 @@ static const struct gpio_bank gpio_bank_am33xx[4] = { const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx; +unsigned int get_omap_gpio_count(void) +{ + return ARRAY_SIZE(gpio_bank_am33xx) * 32; +} + #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD) int cpu_mmc_init(bd_t *bis) { diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index b72fadc..950b13f 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -65,6 +65,11 @@ static const struct gpio_bank gpio_bank_34xx[6] = { const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx; +unsigned int get_omap_gpio_count(void) +{ + return ARRAY_SIZE(gpio_bank_34xx) * 32; +} + #ifdef CONFIG_SPL_BUILD /* * We use static variables because global data is not ready yet. diff --git a/arch/arm/cpu/armv7/omap4/hwinit.c b/arch/arm/cpu/armv7/omap4/hwinit.c index 81f5a48..3212980 100644 --- a/arch/arm/cpu/armv7/omap4/hwinit.c +++ b/arch/arm/cpu/armv7/omap4/hwinit.c @@ -51,6 +51,11 @@ static const struct gpio_bank gpio_bank_44xx[6] = { const struct gpio_bank *const omap_gpio_bank = gpio_bank_44xx; +unsigned int get_omap_gpio_count(void) +{ + return ARRAY_SIZE(gpio_bank_44xx) * 32; +} + #ifdef CONFIG_SPL_BUILD /* * Some tuning of IOs for optimal power and performance diff --git a/arch/arm/cpu/armv7/omap5/hwinit.c b/arch/arm/cpu/armv7/omap5/hwinit.c index 11ba36b..58c77e7 100644 --- a/arch/arm/cpu/armv7/omap5/hwinit.c +++ b/arch/arm/cpu/armv7/omap5/hwinit.c @@ -56,6 +56,11 @@ static struct gpio_bank gpio_bank_54xx[8] = { const struct gpio_bank *const omap_gpio_bank = gpio_bank_54xx; +unsigned int get_omap_gpio_count(void) +{ + return ARRAY_SIZE(gpio_bank_54xx) * 32; +} + #ifdef CONFIG_SPL_BUILD /* LPDDR2 specific IO settings */ static void io_settings_lpddr2(void) diff --git a/arch/arm/include/asm/omap_gpio.h b/arch/arm/include/asm/omap_gpio.h index 1ebfa86..5e25707 100644 --- a/arch/arm/include/asm/omap_gpio.h +++ b/arch/arm/include/asm/omap_gpio.h @@ -46,6 +46,7 @@ struct gpio_bank { }; extern const struct gpio_bank *const omap_gpio_bank; +extern unsigned int get_omap_gpio_count(void); #define METHOD_GPIO_24XX 4 diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c index a30d7f0..1088803 100644 --- a/drivers/gpio/omap_gpio.c +++ b/drivers/gpio/omap_gpio.c @@ -55,7 +55,7 @@ static inline int get_gpio_index(int gpio) int gpio_is_valid(int gpio) { - return (gpio >= 0) && (gpio < 192); + return (gpio >= 0) && (gpio < get_omap_gpio_count()); } static int check_gpio(int gpio)