All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rajeshwari Shinde <rajeshwari.s@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4 V3] EXYNOS5: GPIO: Enable GPIO Command for EXYNOS5
Date: Thu, 07 Feb 2013 17:30:30 +0530	[thread overview]
Message-ID: <1360238430-27715-5-git-send-email-rajeshwari.s@samsung.com> (raw)
In-Reply-To: <1360238430-27715-1-git-send-email-rajeshwari.s@samsung.com>

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 <rajeshwari.s@samsung.com>
---
Changes in V2:
        - New patch
Changes in V3:
	- Created a table to know the base address of input bank.
 arch/arm/cpu/armv7/exynos/pinmux.c      |   50 +++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-exynos/gpio.h |    8 +++++
 include/configs/exynos5250-dt.h         |    1 +
 3 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c b/arch/arm/cpu/armv7/exynos/pinmux.c
index 28b0306..a01ce0c 100644
--- a/arch/arm/cpu/armv7/exynos/pinmux.c
+++ b/arch/arm/cpu/armv7/exynos/pinmux.c
@@ -27,6 +27,21 @@
 #include <asm/arch/pinmux.h>
 #include <asm/arch/sromc.h>
 
+struct gpio_name_num_table exynos5_gpio_table[] = {
+	{ 'a', GPIO_A00 },
+	{ 'b', GPIO_B00 },
+	{ 'c', GPIO_C00 },
+	{ 'd', GPIO_D00 },
+	{ 'y', GPIO_Y00 },
+	{ 'x', GPIO_X00 },
+	{ 'e', GPIO_E00 },
+	{ 'f', GPIO_F00 },
+	{ 'g', GPIO_G00 },
+	{ 'h', GPIO_H00 },
+	{ 'v', GPIO_V00 },
+	{ 'z', GPIO_Z0 },
+};
+
 static void exynos5_uart_config(int peripheral)
 {
 	int i, start, count;
@@ -448,3 +463,38 @@ int pinmux_decode_periph_id(const void *blob, int node)
 		return PERIPH_ID_NONE;
 }
 #endif
+
+int 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 = 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/arch/arm/include/asm/arch-exynos/gpio.h b/arch/arm/include/asm/arch-exynos/gpio.h
index 38b959d..016a112 100644
--- a/arch/arm/include/asm/arch-exynos/gpio.h
+++ b/arch/arm/include/asm/arch-exynos/gpio.h
@@ -657,6 +657,14 @@ static inline unsigned int s5p_gpio_part_max(int nr)
 void gpio_cfg_pin(int gpio, int cfg);
 void gpio_set_pull(int gpio, int mode);
 void gpio_set_drv(int gpio, int mode);
+
+struct gpio_name_num_table {
+	char bank;
+	unsigned int base;
+};
+
+int name_to_gpio(const char *name);
+#define name_to_gpio(n) name_to_gpio(n)
 #endif
 
 /* Pin configurations */
diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
index b1b24a9..a32cc3e 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -113,6 +113,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
-- 
1.7.4.4

  parent reply	other threads:[~2013-02-07 12:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07 12:00 [U-Boot] [PATCH 0/4 V3] EXYNOS5: Add GPIO numbering feature Rajeshwari Shinde
2013-02-07 12:00 ` [U-Boot] [PATCH 1/4 V3] S5P: GPIO: Add generic pin numbering API's Rajeshwari Shinde
2013-02-08 16:11   ` Simon Glass
2013-02-07 12:00 ` [U-Boot] [PATCH 2/4 V3] EXYNOS5: Add gpio pin numbering feature Rajeshwari Shinde
2013-02-08  3:57   ` Minkyu Kang
2013-02-17  6:21   ` Simon Glass
2013-02-18 12:10     ` Rajeshwari Birje
2013-02-21 20:53       ` Simon Glass
2013-02-07 12:00 ` [U-Boot] [PATCH 3/4 V3] S5P: Rename GPIO definitions Rajeshwari Shinde
2013-02-08 16:04   ` Simon Glass
2013-02-07 12:00 ` Rajeshwari Shinde [this message]
2013-02-08  4:31   ` [U-Boot] [PATCH 4/4 V3] EXYNOS5: GPIO: Enable GPIO Command for EXYNOS5 Minkyu Kang
2013-02-08 16:08   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360238430-27715-5-git-send-email-rajeshwari.s@samsung.com \
    --to=rajeshwari.s@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.