From patchwork Wed Sep 5 07:47:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 181768 X-Patchwork-Delegate: promsoft@gmail.com 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 2DDAD2C0089 for ; Wed, 5 Sep 2012 17:48:21 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8CF9128161; Wed, 5 Sep 2012 09:48:18 +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 B9pD3oGDzHxv; Wed, 5 Sep 2012 09:48:17 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 60A3A2815A; Wed, 5 Sep 2012 09:48:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 50AD32815A for ; Wed, 5 Sep 2012 09:48:12 +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 aIK1UzAQ0uR1 for ; Wed, 5 Sep 2012 09:48:09 +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 mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by theia.denx.de (Postfix) with ESMTP id 8D3C22813F for ; Wed, 5 Sep 2012 09:48:08 +0200 (CEST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9V0036E9NPFFT0@mailout1.samsung.com> for u-boot@lists.denx.de; Wed, 05 Sep 2012 16:48:03 +0900 (KST) X-AuditID: cbfee61b-b7f056d000002c30-cf-504703b23ce0 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 45.E9.11312.2B307405; Wed, 05 Sep 2012 16:48:03 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M9V004FX9NVL850@mmp2.samsung.com> for u-boot@lists.denx.de; Wed, 05 Sep 2012 16:48:02 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Wed, 05 Sep 2012 09:47:46 +0200 Message-id: <1346831266-28127-1-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFJMWRmVeSWpSXmKPExsVy+t9jQd3NzO4BBns0Ld7u7WR3YPQ4e2cH YwBjFJdNSmpOZllqkb5dAlfGjJvTWQuuiVR0X/7F2sDYLdjFyMEhIWAisXchUxcjJ5ApJnHh 3nq2LkYuDiGB6YwSk04eY4dwFjNJ3Pz8ig2kik1AT+Lz3adgHSICEhK/+q8yghQxCyxklPh7 fwoLSEJYIFzi158XzCA2i4CqxLLre8CaeQXcJO4dWAe1Tl7i6f0+tgmM3AsYGVYxiqYWJBcU J6XnGukVJ+YWl+al6yXn525iBPvwmfQOxlUNFocYBTgYlXh4Ff66BQixJpYVV+YeYpTgYFYS 4b292jVAiDclsbIqtSg/vqg0J7X4EKM0B4uSOK/TObsAIYH0xJLU7NTUgtQimCwTB6dUA+Mk oRtaXs5r1nn92FbpvXQLv6NA4nl7mwPVAr47L4nzbcu261t9MP7+jlVSIoUmPAKZMp+5z8zV /Sh4yYT/yfFeb8eEz8K8YvWdBzd4dzft+xUs/iPuSZ0iv8/OWa/izJXSDN+dyjvqyfmVIybS RbT4gEl7/AvDJoOJdVMm3FgRvuZz7b4Za5VYijMSDbWYi4oTAQkgrjndAQAA Cc: Kyungmin Park Subject: [U-Boot] [PATCH] gpio:fix: Proper handling of GPIO subsystem parts at Samsung devices 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Now proper GPIO parts numbering is handled at Samsung devices. This fix is necessary for code using GPIO located at other banks than first. Test HW: - Exynos4210 - Trats - S5PC110 - goni Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Cc: Minkyu Kang --- arch/arm/include/asm/arch-exynos/gpio.h | 19 +++++++++++++++++++ arch/arm/include/asm/arch-s5pc1xx/gpio.h | 7 ++++++- drivers/gpio/s5p_gpio.c | 6 ++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/arch-exynos/gpio.h b/arch/arm/include/asm/arch-exynos/gpio.h index 7a9bb90..fdb52fa 100644 --- a/arch/arm/include/asm/arch-exynos/gpio.h +++ b/arch/arm/include/asm/arch-exynos/gpio.h @@ -204,6 +204,25 @@ static inline unsigned int s5p_gpio_base(int nr) return 0; } +static inline unsigned int s5p_gpio_part_max(int nr) +{ + if (cpu_is_exynos5()) { + if (nr < EXYNOS5_GPIO_PART1_MAX) + return 0; + else if (nr < EXYNOS5_GPIO_PART2_MAX) + return EXYNOS5_GPIO_PART1_MAX; + else + return EXYNOS5_GPIO_PART2_MAX; + + } else if (cpu_is_exynos4()) { + if (nr < EXYNOS4_GPIO_PART1_MAX) + return 0; + else + return EXYNOS4_GPIO_PART1_MAX; + } + + return 0; +} #endif /* Pin configurations */ diff --git a/arch/arm/include/asm/arch-s5pc1xx/gpio.h b/arch/arm/include/asm/arch-s5pc1xx/gpio.h index 76b901b..00e498d 100644 --- a/arch/arm/include/asm/arch-s5pc1xx/gpio.h +++ b/arch/arm/include/asm/arch-s5pc1xx/gpio.h @@ -143,7 +143,12 @@ static inline unsigned int s5p_gpio_base(int nr) return S5PC110_GPIO_BASE; } -#define s5pc110_gpio_get_nr(bank, pin) \ +static inline unsigned int s5p_gpio_part_max(int nr) +{ + return 0; +} + +#define s5pc110_gpio_get_nr(bank, pin) \ ((((((unsigned int)&(((struct s5pc110_gpio *)S5PC110_GPIO_BASE)->bank))\ - S5PC110_GPIO_BASE) / sizeof(struct s5p_gpio_bank)) \ * GPIO_PER_BANK) + pin) diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index 47f3213..656bf4a 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -144,9 +144,11 @@ void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode) struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned gpio) { - int bank = gpio / GPIO_PER_BANK; - bank *= sizeof(struct s5p_gpio_bank); + int bank; + unsigned g = gpio - s5p_gpio_part_max(gpio); + bank = g / GPIO_PER_BANK; + bank *= sizeof(struct s5p_gpio_bank); return (struct s5p_gpio_bank *) (s5p_gpio_base(gpio) + bank); }