diff mbox

[3/3,V5] EXYNOS5: GPIO: Enable GPIO Command for EXYNOS5

Message ID 1364990064-30688-4-git-send-email-rajeshwari.s@samsung.com
State New
Headers show

Commit Message

Rajeshwari Shinde April 3, 2013, 11:54 a.m. UTC
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.
Changes in V4:
	- Moved the function name_to_gpio to s5p gpio driver and 
	renamed to s5p_name_to_gpio.
Changes in V5:
	- Rebased on latest u-boot-samsung tree
 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(-)

Comments

Simon Glass May 11, 2013, 6:41 p.m. UTC | #1
On Wed, Apr 3, 2013 at 5:54 AM, Rajeshwari Shinde
<rajeshwari.s@samsung.com> wrote:
> 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>

Acked-by: Simon Glass <sjg@chromium.org>

> ---
> 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.
> Changes in V5:
>         - Rebased on latest u-boot-samsung tree
>  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(-)
>
Minkyu Kang May 21, 2013, 7:44 a.m. UTC | #2
Dear Rajeshwari Shinde,

On 03/04/13 20:54, Rajeshwari Shinde wrote:
> 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.
> Changes in V4:
> 	- Moved the function name_to_gpio to s5p gpio driver and 
> 	renamed to s5p_name_to_gpio.
> Changes in V5:
> 	- Rebased on latest u-boot-samsung tree
>  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 d8000af..9b31dc2 100644
> --- a/arch/arm/include/asm/arch-exynos/gpio.h
> +++ b/arch/arm/include/asm/arch-exynos/gpio.h
> @@ -660,6 +660,14 @@ static inline unsigned int get_bank_num(void)
>  		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 d6650c3..824977b 100644
> --- a/drivers/gpio/s5p_gpio.c
> +++ b/drivers/gpio/s5p_gpio.c
> @@ -36,6 +36,21 @@
>  #define RATE_MASK(x)		(0x1 << (x + 16))
>  #define RATE_SET(x)		(0x1 << (x + 16))
>  
> +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;
> @@ -238,3 +253,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++;

Maybe you missing my comments on V3 patch.
Please check.
http://lists.denx.de/pipermail/u-boot/2013-February/146206.html

> +
> +	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 cbd1c4e..46a4e75 100644
> --- a/include/configs/exynos5250-dt.h
> +++ b/include/configs/exynos5250-dt.h
> @@ -122,6 +122,7 @@
>  #define CONFIG_CMD_FAT
>  #define CONFIG_CMD_NET
>  #define CONFIG_CMD_HASH
> +#define CONFIG_CMD_GPIO
>  
>  #define CONFIG_BOOTDELAY		3
>  #define CONFIG_ZERO_BOOTDELAY_CHECK
> 

Thanks,
Minkyu Kang.
diff mbox

Patch

diff --git a/arch/arm/include/asm/arch-exynos/gpio.h b/arch/arm/include/asm/arch-exynos/gpio.h
index d8000af..9b31dc2 100644
--- a/arch/arm/include/asm/arch-exynos/gpio.h
+++ b/arch/arm/include/asm/arch-exynos/gpio.h
@@ -660,6 +660,14 @@  static inline unsigned int get_bank_num(void)
 		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 d6650c3..824977b 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -36,6 +36,21 @@ 
 #define RATE_MASK(x)		(0x1 << (x + 16))
 #define RATE_SET(x)		(0x1 << (x + 16))
 
+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;
@@ -238,3 +253,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 cbd1c4e..46a4e75 100644
--- a/include/configs/exynos5250-dt.h
+++ b/include/configs/exynos5250-dt.h
@@ -122,6 +122,7 @@ 
 #define CONFIG_CMD_FAT
 #define CONFIG_CMD_NET
 #define CONFIG_CMD_HASH
+#define CONFIG_CMD_GPIO
 
 #define CONFIG_BOOTDELAY		3
 #define CONFIG_ZERO_BOOTDELAY_CHECK