From patchwork Thu Mar 21 11:33:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 15456 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9472823E14 for ; Thu, 21 Mar 2013 11:30:32 +0000 (UTC) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3B968A19125 for ; Thu, 21 Mar 2013 11:30:32 +0000 (UTC) Received: by mail-vc0-f180.google.com with SMTP id m17so2152500vca.39 for ; Thu, 21 Mar 2013 04:30:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state; bh=Y35hWnoOEO/YYuz0PC/BTm/zAZAJgLd0tZbRpN5E130=; b=VrL/XAeh5q/4y+19E+JoKtMvQ3fPsNYlCUfLfKpQzDy4bOR53sntXj1HuzrYBBN6o8 6d0K9NYzZP6yJ2RZxm9JESGaGyvTUm0oK3BwozeN8cC90KJq55cSQxEE7D2u1tIroJdg FhJj084XztJmyFvMMweGfMc4bc4atV+SEnUsaR3eK2zv1XBqS+q2iAFbi26SdEWhAxIG mGhX1N+VFRPQVQqSje1mNWJTvtqr0J9C3yTtWtFDM69YOOl2HWeOfJAcOmWsdW0lNncg 8829mlRFqYoFxmqLL1HDmwRYUKnUKAUc2lYqQho+Eb9qZEZKaTzKAkNaDJ8lQ3Qeo2mw JBOQ== X-Received: by 10.52.20.239 with SMTP id q15mr10965574vde.73.1363865431681; Thu, 21 Mar 2013 04:30:31 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.233.198 with SMTP id ty6csp55849vec; Thu, 21 Mar 2013 04:30:31 -0700 (PDT) X-Received: by 10.68.212.135 with SMTP id nk7mr14366991pbc.120.1363865430447; Thu, 21 Mar 2013 04:30:30 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id te10si6030260pab.9.2013.03.21.04.30.29; Thu, 21 Mar 2013 04:30:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MK000F62DAO9B31@mailout3.samsung.com>; Thu, 21 Mar 2013 20:30:29 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id AC.4D.07735.35FEA415; Thu, 21 Mar 2013 20:30:27 +0900 (KST) X-AuditID: cbfee68e-b7f946d000001e37-75-514aef533a9e Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 9B.47.17838.35FEA415; Thu, 21 Mar 2013 20:30:27 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MK000DUVD5RQ040@mmp1.samsung.com>; Thu, 21 Mar 2013 20:30:27 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org Subject: [PATCH 3/3 V4] EXYNOS5: GPIO: Enable GPIO Command for EXYNOS5 Date: Thu, 21 Mar 2013 17:03:41 +0530 Message-id: <1363865621-7570-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1363865621-7570-1-git-send-email-rajeshwari.s@samsung.com> References: <1363865621-7570-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsWyRsSkWjf4vVegwa0NEhYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyZrc0MxbMl6q4dXIxewNjm2gXIyeHhICJxPzHZ5kg bDGJC/fWs3UxcnEICSxllFiz+TRLFyMHWNGxvhiI+CJGietLd0MVTWSSaFv1gB2km03ASGLr yWmMILaIgITEr/6rYDazQIzE6/0/2EBsYQE3iYmTd4PVswioSixYPIkFxOYVcJe49egUG8QV ChLHpn5lBbE5BTwkGv69ZQaxhYBq2jdsZQZZLCFwn03i9YvjLBCDBCS+TT4EdamsxKYDzBBz JCUOrrjBMoFReAEjwypG0dSC5ILipPQiI73ixNzi0rx0veT83E2MwHA8/e9Z3w7GmwesDzEm A42byCwlmpwPDOe8knhDYzMjC1MTU2Mjc0sz0oSVxHnVWqwDhQTSE0tSs1NTC1KL4otKc1KL DzEycXBKNTDaROptOzy9wUdqy7uoy27THiw9WPa4ndmtZqNPXuv3+67Kiy2ZRGZlV7fFsb8X OyX6NdEnRcwpps3U4GWMWChX0Y+dTg/N6rdsyl3/I9ruVFugj5Lyqzk2MtlXpQ5+CPDhbPlU Uc2QXbL5+7wbrQwTbK6eEksylnTnlQq/WdGQw/ZA8nThKSWW4oxEQy3mouJEAINH0VFdAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsVy+t9jAd3g916BBj8ecFs8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzJjd0sxYMF+q 4tbJxewNjG2iXYwcHBICJhLH+mK6GDmBTDGJC/fWs3UxcnEICSxilLi+dDeUM5FJom3VA3aQ KjYBI4mtJ6cxgtgiAhISv/qvgtnMAjESr/f/YAOxhQXcJCZO3g1WzyKgKrFg8SQWEJtXwF3i 1qNTbBDbFCSOTf3KCmJzCnhINPx7ywxiCwHVtG/YyjyBkXcBI8MqRtHUguSC4qT0XEO94sTc 4tK8dL3k/NxNjOBgfya1g3Flg8UhRgEORiUeXo4nnoFCrIllxZW5hxglOJiVRHh1nnoFCvGm JFZWpRblxxeV5qQWH2JMBrpqIrOUaHI+MBLzSuINjU3MTY1NLU0sTMwsSRNWEuc90GodKCSQ nliSmp2aWpBaBLOFiYNTqoHRoIzr/6Yr/z//MQr/W8fwX1Zp1YTz/3b1PDkl/fZWvtHhwrUH jkVE7iuzaS/MYepgPXVsp1fSzTMaHPpOz16G7OK9up35epralKNrFheslWzr+PVbWVdh/Zlb x2ZYPOj/lauw5P0M57VXzXUVylYWKGWExp++2LZe2KhyxXy5OdcO2J9KSj65VomlOCPRUIu5 qDgRALRcsbS6AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQlmTawc2sWfkRcl3r8obKZqVkYq38iAyBpgvS+rc512TZ9tb2DkoHc0MXiiRBkJIux8CrWe This patch enables GPIO Command for EXYNOS5. Function has been added to asm/gpio.h to decode the input gpio name to gpio number. example: gpio set gpa00 Signed-off-by: Rajeshwari Shinde --- Changes in V2: - New patch Changes in V3: - Created a table to know the base address of input bank. Changes in V4: - Moved the function name_to_gpio to s5p gpio driver and renamed to s5p_name_to_gpio. arch/arm/include/asm/arch-exynos/gpio.h | 8 +++++ drivers/gpio/s5p_gpio.c | 49 +++++++++++++++++++++++++++++++ include/configs/exynos5250-dt.h | 1 + 3 files changed, 58 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/arch-exynos/gpio.h b/arch/arm/include/asm/arch-exynos/gpio.h index 0b8e35e..7c0df0b 100644 --- a/arch/arm/include/asm/arch-exynos/gpio.h +++ b/arch/arm/include/asm/arch-exynos/gpio.h @@ -668,6 +668,14 @@ static inline unsigned int s5p_gpio_part_max(int nr) return 0; } +struct gpio_name_num_table { + char bank; + unsigned int base; +}; + +int s5p_name_to_gpio(const char *name); +#define name_to_gpio(n) s5p_name_to_gpio(n) + void gpio_cfg_pin(int gpio, int cfg); void gpio_set_pull(int gpio, int mode); void gpio_set_drv(int gpio, int mode); diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c index a503137..312d352 100644 --- a/drivers/gpio/s5p_gpio.c +++ b/drivers/gpio/s5p_gpio.c @@ -57,6 +57,21 @@ static const struct gpio_info gpio_data[EXYNOS5_GPIO_NUM_PARTS] = { #define HAVE_GENERIC_GPIO #endif +struct gpio_name_num_table exynos5_gpio_table[] = { + { 'a', EXYNOS5_GPIO_A00 }, + { 'b', EXYNOS5_GPIO_B00 }, + { 'c', EXYNOS5_GPIO_C00 }, + { 'd', EXYNOS5_GPIO_D00 }, + { 'y', EXYNOS5_GPIO_Y00 }, + { 'x', EXYNOS5_GPIO_X00 }, + { 'e', EXYNOS5_GPIO_E00 }, + { 'f', EXYNOS5_GPIO_F00 }, + { 'g', EXYNOS5_GPIO_G00 }, + { 'h', EXYNOS5_GPIO_H00 }, + { 'v', EXYNOS5_GPIO_V00 }, + { 'z', EXYNOS5_GPIO_Z0 }, +}; + void s5p_gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg) { unsigned int value; @@ -259,3 +274,37 @@ void gpio_cfg_pin(int gpio, int cfg) s5p_gpio_cfg_pin(s5p_gpio_get_bank(gpio), s5p_gpio_get_pin(gpio), cfg); } + +int s5p_name_to_gpio(const char *name) +{ + unsigned int num, i; + + name++; + + if (*name == 'p') + ++name; + + for (i = 0; i < ARRAY_SIZE(exynos5_gpio_table); i++) { + if (*name == exynos5_gpio_table[i].bank) { + if (*name == 'c') { + name++; + num = simple_strtoul(name, NULL, 10); + if (num >= 40) { + num = EXYNOS5_GPIO_C40 + (num - 40); + } else { + num = simple_strtoul(name, NULL, 8); + num = exynos5_gpio_table[i].base + num; + } + } else { + name++; + num = simple_strtoul(name, NULL, 8); + num = exynos5_gpio_table[i].base + num; + } + break; + } + } + + if (i == ARRAY_SIZE(exynos5_gpio_table)) + return -1; + return num; +} diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h index 9fab0fb..5a8a2fb 100644 --- a/include/configs/exynos5250-dt.h +++ b/include/configs/exynos5250-dt.h @@ -115,6 +115,7 @@ #define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT #define CONFIG_CMD_NET +#define CONFIG_CMD_GPIO #define CONFIG_BOOTDELAY 3 #define CONFIG_ZERO_BOOTDELAY_CHECK