NetBSD/usr.sbin/gpioctl/gpioctl.8

177 lines
3.6 KiB
Groff
Raw Normal View History

.\" $NetBSD: gpioctl.8,v 1.2 2005/09/27 09:16:20 wiz Exp $
.\" $OpenBSD: gpioctl.8,v 1.5 2004/12/02 05:11:40 grange Exp $
.\"
.\" Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd September 26, 2005
.Dt GPIOCTL 8
.Os
.Sh NAME
.Nm gpioctl
.Nd control GPIO devices
.Sh SYNOPSIS
.Nm
.Op Fl hq
.Op Fl d Ar device
.Op Ar pin
.Op Ar 0 | 1 | 2
.Nm
.Op Fl hq
.Op Fl d Ar device
.Fl c
.Ar pin
.Op Ar flags
.Sh DESCRIPTION
The
.Nm
program allows manipulation of
.Tn GPIO
(General Purpose Input/Output) device pins.
Such devices can be either part of the chipset or embedded
.Tn CPU ,
or a separate chip.
The usual way of using
.Tn GPIO
is to connect some simple devices such as LEDs, 1-wire thermal sensors,
etc., to its pins.
.Pp
Each
.Tn GPIO
device has an associated device file in the
.Pa /dev
directory.
By default
.Nm
uses
.Pa /dev/gpio0 ,
which corresponds to the first found
.Tn GPIO
device in the system.
If more than one
.Tn GPIO
device is present, an alternative device file can be specified with the
.Fl d
option in order to access a particular
.Tn GPIO
device.
.Pp
When executed without any arguments,
.Nm
reads information about the
.Tn GPIO
device and displays it.
.Pp
.Tn GPIO
pins can be either
.Dq read
or
.Dq written
with the values of logical 0 or 1.
If only a
.Ar pin
number is specified on the command line, the pin state will be read
from the
.Tn GPIO
controller and displayed.
To write to a pin, a value must be specified after the
.Ar pin
number.
Values can be either 0 or 1.
A value of 2 has a special meaning: it
.Dq toggles
the pin, i.e. changes its state to the opposite.
.Pp
Each pin can be configured with different flags with the
.Fl c
option.
The following configuration flags are supported by the
.Tn GPIO
framework:
.Pp
.Bl -tag -width XXXXXXX -offset indent -compact
.It in
input direction
.It out
output direction
.It inout
bi-directional
.It od
open-drain output
.It pp
push-pull output
.It tri
tri-state (output disabled)
.It pu
internal pull-up enabled
.El
.Pp
Note that not all the flags can be supported by the particular
.Tn GPIO
controller.
The list of supported flags is always displayed when executing
.Nm
with the
.Fl c
option.
If only a
.Ar pin
number is specified on the command line, the current pin flags will be
displayed.
To change pin flags, a new flags set separated by spaces must be
specified after the
.Ar pin
number.
.Pp
The
.Fl q
option causes
.Nm
to operate quietly i.e. nothing is printed to stdout.
The
.Fl h
option displays a usage summary.
.Sh FILES
.Bl -tag -width "/dev/gpiou" -compact
.It /dev/gpio Ns Ar u
GPIO device unit
.Ar u
file.
.El
.Sh EXAMPLES
Configure pin 20 to have push-pull output:
.Pp
.Dl # gpioctl -c 20 out pp
.Pp
Write logical 1 to pin 20:
.Pp
.Dl # gpioctl 20 1
.Sh SEE ALSO
.Xr elansc 4 ,
.Xr gpio 4 ,
.Xr gscpcib 4 ,
.Xr nsclpcsio 4
.Sh HISTORY
The
.Nm
command first appeared in
.Ox 3.6
and
.Nx 4.0 .
.Sh AUTHORS
The
.Nm
program was written by
.An Alexander Yurchenko Aq grange@openbsd.org .