linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: linuxppc-dev@ozlabs.org
Subject: simple gpio driver
Date: Thu, 13 Aug 2009 07:49:42 +0200	[thread overview]
Message-ID: <4A83A976.60608@denx.de> (raw)

Hello Anton,

i am trying to use the arch/powerpc/sysdev/simple_gpio.c driver,
for accessing some gpios, and found, that u8_gpio_get()
returns not only a 1 or a 0, instead it returns the real bit
position from the gpio:

gpio    return
base	value
0	0/0x01
1	0/0x02
2	0/0x04
3	0/0x08
4	0/0x10
5	0/0x20
6	0/0x40
7	0/0x80

I also use the arch/powerpc/platforms/52xx/mpc52xx_gpio.c and
mpc52xx_gpt.c drivers, they all return for a gpio just a 1 or 0,
which seems correct to me, because a gpio can have only 1 or 0
as state ... what do you think?

I solved this issue (if it is) with the following patch:

diff --git a/arch/powerpc/sysdev/simple_gpio.c b/arch/powerpc/sysdev/simple_gpio.c
index 43c4569..bb0d79c 100644
--- a/arch/powerpc/sysdev/simple_gpio.c
+++ b/arch/powerpc/sysdev/simple_gpio.c
@@ -46,7 +46,7 @@ static int u8_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 {
 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);

-	return in_8(mm_gc->regs) & u8_pin2mask(gpio);
+	return (in_8(mm_gc->regs) & u8_pin2mask(gpio) ? 1 : 0);
 }

 static void u8_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)

bye
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

             reply	other threads:[~2009-08-13  5:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-13  5:49 Heiko Schocher [this message]
2009-08-17 21:18 ` simple gpio driver Grant Likely
2009-08-17 23:38   ` Anton Vorontsov
2009-08-18  5:25     ` Heiko Schocher
2009-08-18  5:24   ` Heiko Schocher

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=4A83A976.60608@denx.de \
    --to=hs@denx.de \
    --cc=avorontsov@ru.mvista.com \
    --cc=linuxppc-dev@ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).