Linux Samsung SOC development
 help / color / mirror / Atom feed
* [PATCH] ARM: SAMSUNG: Fix on s5p_gpio_[get,set]_drvstr
@ 2010-08-30  3:31 Kukjin Kim
  2010-08-30  9:52 ` Kukjin Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Kukjin Kim @ 2010-08-30  3:31 UTC (permalink / raw)
  To: linux-samsung-soc; +Cc: ben-linux, Kukjin Kim

This patch fixes bug on gpio drive strength helper function.

The offset should be like follwoing.
-       off = chip->chip.base - pin;
+       off = pin - chip->chip.base;

In the s5p_gpio_get_drvstr(),
the second line is unnecessary, because overwrite drvstr.
        drvstr = __raw_readl(reg);
-       drvstr = 0xffff & (0x3 << shift);

And need 2bit masking before return the drvstr value.
        drvstr = drvstr >> shift;
+       drvstr &= 0x3;

In the s5p_gpio_set_drvstr(), need relevant bit clear.
        tmp = __raw_readl(reg);
+       tmp &= ~(0x3 << shift);
        tmp |= drvstr << shift;

Reported-by: Janghyuck Kim <janghyuck.kim@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
---
 arch/arm/plat-samsung/gpio-config.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/arm/plat-samsung/gpio-config.c b/arch/arm/plat-samsung/gpio-config.c
index 57b68a5..e3d41ea 100644
--- a/arch/arm/plat-samsung/gpio-config.c
+++ b/arch/arm/plat-samsung/gpio-config.c
@@ -273,13 +273,13 @@ s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin)
 	if (!chip)
 		return -EINVAL;
 
-	off = chip->chip.base - pin;
+	off = pin - chip->chip.base;
 	shift = off * 2;
 	reg = chip->base + 0x0C;
 
 	drvstr = __raw_readl(reg);
-	drvstr = 0xffff & (0x3 << shift);
 	drvstr = drvstr >> shift;
+	drvstr &= 0x3;
 
 	return (__force s5p_gpio_drvstr_t)drvstr;
 }
@@ -296,11 +296,12 @@ int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr)
 	if (!chip)
 		return -EINVAL;
 
-	off = chip->chip.base - pin;
+	off = pin - chip->chip.base;
 	shift = off * 2;
 	reg = chip->base + 0x0C;
 
 	tmp = __raw_readl(reg);
+	tmp &= ~(0x3 << shift);
 	tmp |= drvstr << shift;
 
 	__raw_writel(tmp, reg);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] ARM: SAMSUNG: Fix on s5p_gpio_[get,set]_drvstr
  2010-08-30  3:31 [PATCH] ARM: SAMSUNG: Fix on s5p_gpio_[get,set]_drvstr Kukjin Kim
@ 2010-08-30  9:52 ` Kukjin Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Kukjin Kim @ 2010-08-30  9:52 UTC (permalink / raw)
  To: 'Kukjin Kim', linux-samsung-soc; +Cc: ben-linux, jc.lee

Kukjin Kim wrote:
> 
> This patch fixes bug on gpio drive strength helper function.
> 
> The offset should be like follwoing.
> -       off = chip->chip.base - pin;
> +       off = pin - chip->chip.base;
> 
> In the s5p_gpio_get_drvstr(),
> the second line is unnecessary, because overwrite drvstr.
>         drvstr = __raw_readl(reg);
> -       drvstr = 0xffff & (0x3 << shift);
> 
> And need 2bit masking before return the drvstr value.
>         drvstr = drvstr >> shift;
> +       drvstr &= 0x3;
> 
> In the s5p_gpio_set_drvstr(), need relevant bit clear.
>         tmp = __raw_readl(reg);
> +       tmp &= ~(0x3 << shift);
>         tmp |= drvstr << shift;
> 
> Reported-by: Janghyuck Kim <janghyuck.kim@samsung.com>

Sorry I confused, should be 'Reported-by: Jaecheol Lee <jc.lee@samsung.com>'

> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
> ---
>  arch/arm/plat-samsung/gpio-config.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/plat-samsung/gpio-config.c
b/arch/arm/plat-samsung/gpio-
> config.c
> index 57b68a5..e3d41ea 100644
> --- a/arch/arm/plat-samsung/gpio-config.c
> +++ b/arch/arm/plat-samsung/gpio-config.c
> @@ -273,13 +273,13 @@ s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int
pin)
>  	if (!chip)
>  		return -EINVAL;
> 
> -	off = chip->chip.base - pin;
> +	off = pin - chip->chip.base;
>  	shift = off * 2;
>  	reg = chip->base + 0x0C;
> 
>  	drvstr = __raw_readl(reg);
> -	drvstr = 0xffff & (0x3 << shift);
>  	drvstr = drvstr >> shift;
> +	drvstr &= 0x3;
> 
>  	return (__force s5p_gpio_drvstr_t)drvstr;
>  }
> @@ -296,11 +296,12 @@ int s5p_gpio_set_drvstr(unsigned int pin,
> s5p_gpio_drvstr_t drvstr)
>  	if (!chip)
>  		return -EINVAL;
> 
> -	off = chip->chip.base - pin;
> +	off = pin - chip->chip.base;
>  	shift = off * 2;
>  	reg = chip->base + 0x0C;
> 
>  	tmp = __raw_readl(reg);
> +	tmp &= ~(0x3 << shift);
>  	tmp |= drvstr << shift;
> 
>  	__raw_writel(tmp, reg);
> --
> 1.6.2.5


Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-30  9:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-30  3:31 [PATCH] ARM: SAMSUNG: Fix on s5p_gpio_[get,set]_drvstr Kukjin Kim
2010-08-30  9:52 ` Kukjin Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox