public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Minkyu Kang <mk7.kang@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4 V3] EXYNOS5: GPIO: Enable GPIO Command for EXYNOS5
Date: Fri, 08 Feb 2013 13:31:51 +0900	[thread overview]
Message-ID: <51147FB7.4070701@samsung.com> (raw)
In-Reply-To: <1360238430-27715-5-git-send-email-rajeshwari.s@samsung.com>

Dear Rajeshwari,

On 07/02/13 21:00, 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.
>  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)

This function should be support exynos4 also.

> +{
> +	unsigned int num, i;
> +
> +	name++;

Please check NULL pointer before you use it.
And I think you should check length of name.
"name++" seems to dangerous.

How about parse the string to bank and number before you use?

> +
> +	if (*name == 'p')
> +		++name;

else?
is not error?

> +
> +	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;

			return num;

> +		}
> +	}

	return -1;

> +
> +	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
> 

Thanks.
Minkyu Kang.

  reply	other threads:[~2013-02-08  4:31 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 ` [U-Boot] [PATCH 4/4 V3] EXYNOS5: GPIO: Enable GPIO Command for EXYNOS5 Rajeshwari Shinde
2013-02-08  4:31   ` Minkyu Kang [this message]
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=51147FB7.4070701@samsung.com \
    --to=mk7.kang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox