1 .\" $NetBSD: gpioctl.8,v 1.6 2009/09/25 19:37:03 mbalmer Exp $
3 .\" Copyright (c) 2009 Marc Balmer <marc@msys.ch>
4 .\" Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
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.
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.
18 .Dd September 25, 2009
23 .Nd control GPIO devices
46 .Op Ar on | off | toggle
62 program allows manipulation of GPIO
63 (General Purpose Input/Output) device pins.
64 Such devices can be either part of the chipset or embedded CPU,
66 The usual way of using GPIO
67 is to connect some simple devices such as LEDs and 1-wire thermal sensors
70 Each GPIO device has an associated device file in the
74 can be specified with or without the
82 GPIO pins can be either
86 with the values of logical 0 or 1.
89 number is specified on the command line, the pin state will be read
90 from the GPIO controller and displayed.
91 To write to a pin, a value must be specified after the
94 Values can be either 0 or 1.
95 A value of 2 has a special meaning: it
97 the pin, i.e. changes its state to the opposite.
98 Instead of the numerical values, the word
105 Only pins that have been configured at securelevel 0, typically during system
106 startup, are accessible once the securelevel has been raised.
107 Pins can be given symbolic names for easier use.
108 Besides using individual pins, device drivers that use GPIO pins can be
115 The following configuration
117 are supported by the GPIO framework:
119 .Bl -tag -width Ds -offset indent -compact
131 tri-state (output disabled)
133 internal pull-up enabled
135 internal pull-down enabled
141 pulsate output at a hardware-defined frequency and duty cycle
144 Note that not all the flags may be supported by the particular GPIO controller.
146 When executed with only the
148 device name as argument,
150 reads information about the
152 device and displays it.
153 At securelevel 0 the number of physically available pins is displayed,
154 at higher securelevels the number of configured (set) pins is displayed.
156 The options are as follows:
159 Operate quietly i.e. nothing is printed to stdout.
162 .Bl -tag -width "/dev/gpiou" -compact
163 .It /dev/gpio Ns Ar u
169 Configure pin 20 to have push-pull output:
171 .Dl # gpioctl gpio0 20 set out pp
173 Write logical 1 to pin 20:
175 .Dl # gpioctl gpio0 20 1
183 .Dl # gpioctl gpio0 attach gpioow 4 0x01
185 Detach the gpioow0 device:
187 .Dl # gpioctl gpio0 detach gpioow0
189 Configure pin 5 as output and name it error_led:
191 .Dl # gpioctl gpio0 5 set out error_led
193 Toggle the error_led:
195 .Dl # gpioctl gpio0 error_led 2
201 command first appeared in
208 program was written by
209 .An Alexander Yurchenko Aq grange@openbsd.org .
210 Device attachment was added by
211 .An Marc Balmer Aq marc@msys.ch .