xref: /netbsd-src/usr.sbin/gpioctl/gpioctl.8 (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1.\" $NetBSD: gpioctl.8,v 1.2 2005/09/27 09:16:20 wiz Exp $
2.\"	$OpenBSD: gpioctl.8,v 1.5 2004/12/02 05:11:40 grange Exp $
3.\"
4.\" Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd September 26, 2005
19.Dt GPIOCTL 8
20.Os
21.Sh NAME
22.Nm gpioctl
23.Nd control GPIO devices
24.Sh SYNOPSIS
25.Nm
26.Op Fl hq
27.Op Fl d Ar device
28.Op Ar pin
29.Op Ar 0 | 1 | 2
30.Nm
31.Op Fl hq
32.Op Fl d Ar device
33.Fl c
34.Ar pin
35.Op Ar flags
36.Sh DESCRIPTION
37The
38.Nm
39program allows manipulation of
40.Tn GPIO
41(General Purpose Input/Output) device pins.
42Such devices can be either part of the chipset or embedded
43.Tn CPU ,
44or a separate chip.
45The usual way of using
46.Tn GPIO
47is to connect some simple devices such as LEDs, 1-wire thermal sensors,
48etc., to its pins.
49.Pp
50Each
51.Tn GPIO
52device has an associated device file in the
53.Pa /dev
54directory.
55By default
56.Nm
57uses
58.Pa /dev/gpio0 ,
59which corresponds to the first found
60.Tn GPIO
61device in the system.
62If more than one
63.Tn GPIO
64device is present, an alternative device file can be specified with the
65.Fl d
66option in order to access a particular
67.Tn GPIO
68device.
69.Pp
70When executed without any arguments,
71.Nm
72reads information about the
73.Tn GPIO
74device and displays it.
75.Pp
76.Tn GPIO
77pins can be either
78.Dq read
79or
80.Dq written
81with the values of logical 0 or 1.
82If only a
83.Ar pin
84number is specified on the command line, the pin state will be read
85from the
86.Tn GPIO
87controller and displayed.
88To write to a pin, a value must be specified after the
89.Ar pin
90number.
91Values can be either 0 or 1.
92A value of 2 has a special meaning: it
93.Dq toggles
94the pin, i.e. changes its state to the opposite.
95.Pp
96Each pin can be configured with different flags with the
97.Fl c
98option.
99The following configuration flags are supported by the
100.Tn GPIO
101framework:
102.Pp
103.Bl -tag -width XXXXXXX -offset indent -compact
104.It in
105input direction
106.It out
107output direction
108.It inout
109bi-directional
110.It od
111open-drain output
112.It pp
113push-pull output
114.It tri
115tri-state (output disabled)
116.It pu
117internal pull-up enabled
118.El
119.Pp
120Note that not all the flags can be supported by the particular
121.Tn GPIO
122controller.
123The list of supported flags is always displayed when executing
124.Nm
125with the
126.Fl c
127option.
128If only a
129.Ar pin
130number is specified on the command line, the current pin flags will be
131displayed.
132To change pin flags, a new flags set separated by spaces must be
133specified after the
134.Ar pin
135number.
136.Pp
137The
138.Fl q
139option causes
140.Nm
141to operate quietly i.e. nothing is printed to stdout.
142The
143.Fl h
144option displays a usage summary.
145.Sh FILES
146.Bl -tag -width "/dev/gpiou" -compact
147.It /dev/gpio Ns Ar u
148GPIO device unit
149.Ar u
150file.
151.El
152.Sh EXAMPLES
153Configure pin 20 to have push-pull output:
154.Pp
155.Dl # gpioctl -c 20 out pp
156.Pp
157Write logical 1 to pin 20:
158.Pp
159.Dl # gpioctl 20 1
160.Sh SEE ALSO
161.Xr elansc 4 ,
162.Xr gpio 4 ,
163.Xr gscpcib 4 ,
164.Xr nsclpcsio 4
165.Sh HISTORY
166The
167.Nm
168command first appeared in
169.Ox 3.6
170and
171.Nx 4.0 .
172.Sh AUTHORS
173The
174.Nm
175program was written by
176.An Alexander Yurchenko Aq grange@openbsd.org .
177