mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* how to read GPIO values from command line?
@ 2012-02-09 16:34 Robert P. J. Day
  2012-02-09 16:45 ` Eric Bénard
  2012-02-10  7:34 ` Sascha Hauer
  0 siblings, 2 replies; 7+ messages in thread
From: Robert P. J. Day @ 2012-02-09 16:34 UTC (permalink / raw)
  To: U-Boot Version 2 (barebox)


  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.

rday

p.s.  my plan is to port that code to barebox, of course.  first, i
just want to see the values 0,1,0 from those gpio pins based on my
board version.

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

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

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

* Re: how to read GPIO values from command line?
  2012-02-09 16:34 how to read GPIO values from command line? 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-10  7:34 ` Sascha Hauer
  1 sibling, 2 replies; 7+ messages in thread
From: Eric Bénard @ 2012-02-09 16:45 UTC (permalink / raw)
  To: barebox

Le Thu, 9 Feb 2012 11:34:55 -0500 (EST),
"Robert P. J. Day" <rpjday@crashcourse.ca> a écrit :
>   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.
> 
you can check the mux of the pins to be sure they are in GPIO mode.

Eric
-- 
http://eukrea.com/en/news/104-2012

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

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

* Re: how to read GPIO values from command line?
  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
  1 sibling, 0 replies; 7+ messages in thread
From: Robert P. J. Day @ 2012-02-09 17:32 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1531 bytes --]

On Thu, 9 Feb 2012, Eric Bénard wrote:

> Le Thu, 9 Feb 2012 11:34:55 -0500 (EST),
> "Robert P. J. Day" <rpjday@crashcourse.ca> a écrit :
> >   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.
> >
> you can check the mux of the pins to be sure they are in GPIO mode.

  ok, bear with me as i'm in new territory here.  i'm assuming that in
order to do that, i need to configure barebox with
MACH_OMAP_ADVANCED_MUX, yes?  because at the moment, the default is
*not*, as you can see in arch/arm/mach-omap/Kconfig:

config MACH_OMAP_ADVANCED_MUX
        bool "Enable advanced pin muxing"
        depends on MACH_OMAP343xSDP
        default n
        help
          Say Y here if you would like to have complete pin muxing to be
          done at boot time

am i correct in guessing that that's why i'm not getting the values
i'm expecting?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

* Re: how to read GPIO values from command line?
  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
  1 sibling, 1 reply; 7+ messages in thread
From: Robert P. J. Day @ 2012-02-09 18:37 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1147 bytes --]

On Thu, 9 Feb 2012, Eric Bénard wrote:

> Le Thu, 9 Feb 2012 11:34:55 -0500 (EST),
> "Robert P. J. Day" <rpjday@crashcourse.ca> a écrit :
> >   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.
> >
> you can check the mux of the pins to be sure they are in GPIO mode.

  how do i do that from the barebox prompt?  i can see the
gpio-related commands for setting direction and getting/setting
values, but how does one check if those pins are properly in gpio
mode?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

* Re: how to read GPIO values from command line?
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Bénard @ 2012-02-09 18:43 UTC (permalink / raw)
  To: barebox

Le Thu, 9 Feb 2012 13:37:34 -0500 (EST),
"Robert P. J. Day" <rpjday@crashcourse.ca> a écrit :

> On Thu, 9 Feb 2012, Eric Bénard wrote:
> 
> > Le Thu, 9 Feb 2012 11:34:55 -0500 (EST),
> > "Robert P. J. Day" <rpjday@crashcourse.ca> a écrit :
> > >   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.
> > >
> > you can check the mux of the pins to be sure they are in GPIO mode.
> 
>   how do i do that from the barebox prompt?  i can see the
> gpio-related commands for setting direction and getting/setting
> values, but how does one check if those pins are properly in gpio
> mode?
> 
see the corresponding registers with md

Eric
-- 
http://eukrea.com/en/news/104-2012

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

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

* Re: how to read GPIO values from command line?
  2012-02-09 18:43     ` Eric Bénard
@ 2012-02-09 18:54       ` Robert P. J. Day
  0 siblings, 0 replies; 7+ messages in thread
From: Robert P. J. Day @ 2012-02-09 18:54 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1668 bytes --]

On Thu, 9 Feb 2012, Eric Bénard wrote:

> Le Thu, 9 Feb 2012 13:37:34 -0500 (EST),
> "Robert P. J. Day" <rpjday@crashcourse.ca> a écrit :
>
> > On Thu, 9 Feb 2012, Eric Bénard wrote:
> >
> > > Le Thu, 9 Feb 2012 11:34:55 -0500 (EST),
> > > "Robert P. J. Day" <rpjday@crashcourse.ca> a écrit :
> > > >   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.
> > > >
> > > you can check the mux of the pins to be sure they are in GPIO mode.
> >
> >   how do i do that from the barebox prompt?  i can see the
> > gpio-related commands for setting direction and getting/setting
> > values, but how does one check if those pins are properly in gpio
> > mode?
> >
> see the corresponding registers with md

  never mind, i think i just figured out i have a lot more work ahead
of me.  i popped into the panda directory, and noticed that honking
big mux.c file, which i'm guessing i'll have for the beagle as well,
and that's a bit over my head at the moment.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

* Re: how to read GPIO values from command line?
  2012-02-09 16:34 how to read GPIO values from command line? Robert P. J. Day
  2012-02-09 16:45 ` Eric Bénard
@ 2012-02-10  7:34 ` Sascha Hauer
  1 sibling, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-10  7:34 UTC (permalink / raw)
  To: Robert P. J. Day; +Cc: U-Boot Version 2 (barebox)

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

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

end of thread, other threads:[~2012-02-10  7:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09 16:34 how to read GPIO values from command line? 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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox