mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: "U-Boot Version 2 (barebox)" <barebox@lists.infradead.org>
Subject: Re: how to read GPIO values from command line?
Date: Fri, 10 Feb 2012 08:34:06 +0100	[thread overview]
Message-ID: <20120210073406.GD3852@pengutronix.de> (raw)
In-Reply-To: <alpine.DEB.2.02.1202091130540.14123@oneiric>

On Thu, Feb 09, 2012 at 11:34:55AM -0500, Robert P. J. Day wrote:
> 
>   i'm looking at the docs and tried the obvious but it didn't seem to
> work.  in order to recognize the version of beagleboard, i can see
> what happens in the u-boot code:
> 
> /*
>  * Routine: get_board_revision
>  * Description: Detect if we are running on a Beagle revision Ax/Bx,
>  *              C1/2/3, C4 or xM. This can be done by reading
>  *              the level of GPIO173, GPIO172 and GPIO171. This should
>  *              result in
>  *              GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
>  *              GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
>  *              GPIO173, GPIO172, GPIO171: 1 0 1 => C4
>  *              GPIO173, GPIO172, GPIO171: 0 0 0 => xM
>  */
> int get_board_revision(void)
> {
>         int revision;
> 
>         if (!gpio_request(171, "") &&
>             !gpio_request(172, "") &&
>             !gpio_request(173, "")) {
> 
>                 gpio_direction_input(171);
>                 gpio_direction_input(172);
>                 gpio_direction_input(173);
> 
>                 revision = gpio_get_value(173) << 2 |
>                            gpio_get_value(172) << 1 |
>                            gpio_get_value(171);
>         } else {
>                 printf("Error: unable to acquire board revision GPIOs\n");
>                 revision = -1;
>         }
> 
>         return revision;
> }
> 
>   however, in the latest kernel tree, it seems things have changed
> slightly:
> 
> /*
>  * OMAP3 Beagle revision
>  * Run time detection of Beagle revision is done by reading GPIO.
>  * GPIO ID -
>  *      AXBX    = GPIO173, GPIO172, GPIO171: 1 1 1
>  *      C1_3    = GPIO173, GPIO172, GPIO171: 1 1 0
>  *      C4      = GPIO173, GPIO172, GPIO171: 1 0 1
>  *      XMA/XMB = GPIO173, GPIO172, GPIO171: 0 0 0
>  *      XMC = GPIO173, GPIO172, GPIO171: 0 1 0
>  */
> 
>   now that's useful since there are now allegedly different values for
> xM A/B, and xM C, and i have a rev C.
> 
>   so what exactly does one do to read those values?  i tried:
> 
> barebox@Texas Instrument's Beagle:/ gpio_direction_input 171
> barebox@Texas Instrument's Beagle:/ gpio_get_value 171
> 
> but what do i check?  the shell variable $?  i'm not sure what i
> should do next.

Yes, check $?. This assumes that your iomux is set up correctly as Eric
already mentioned. I wonder that there is no iomux setup for the panda
board. You can copy it from U-Boot. It has to arrays of iomux setup:
core_padconf_array_essential and core_padconf_array_non_essential

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2012-02-10  7:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09 16:34 Robert P. J. Day
2012-02-09 16:45 ` Eric Bénard
2012-02-09 17:32   ` Robert P. J. Day
2012-02-09 18:37   ` Robert P. J. Day
2012-02-09 18:43     ` Eric Bénard
2012-02-09 18:54       ` Robert P. J. Day
2012-02-10  7:34 ` Sascha Hauer [this message]

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=20120210073406.GD3852@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=rpjday@crashcourse.ca \
    /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