[BACK]Return to gpio.4 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / man / man4

File: [cvs.NetBSD.org] / src / share / man / man4 / gpio.4 (download)

Revision 1.7, Tue Apr 29 14:07:36 2008 UTC (15 years, 11 months ago) by cegger
Branch: MAIN
CVS Tags: yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, mjf-devfs2-base, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-base2, hpcarm-cleanup-nbase
Branch point for: netbsd-5, jym-xensuspend
Changes since 1.6: +2 -1 lines

gpio(4): Extend with open/close to request/release the ppbus(4) on open/close.
ppbus(4): Extend to attach on gpiobus.
From Hans Rosenfeld from tech-kern:
http://mail-index.netbsd.org/tech-kern/2008/04/28/msg001168.html
Hint: Hans sent me this diff which differs in the one from tech-kern in:
- 2-clause license
- sprinkled some consts

.\" $NetBSD: gpio.4,v 1.7 2008/04/29 14:07:36 cegger Exp $
.\"	$OpenBSD: gpio.4,v 1.5 2004/11/23 09:39:29 reyk 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 January 9, 2008
.Dt GPIO 4
.Os
.Sh NAME
.Nm gpio
.Nd General Purpose Input/Output
.Sh SYNOPSIS
.Cd "gpio* at elansc?"
.Cd "gpio* at gcscpcib?"
.Cd "gpio* at gscpcib?"
.Cd "gpio* at nsclpcsio?"
.Cd "gpio* at ppbus?"
.Pp
.In sys/types.h
.In sys/gpio.h
.In sys/ioctl.h
.Sh DESCRIPTION
The
.Nm
device attaches to the
.Tn GPIO
controller and provides a uniform programming interface to its pins.
.Pp
Each
.Tn GPIO
controller with an attached
.Nm
device has an associated device file under the
.Pa /dev
directory, e.g.\&
.Pa /dev/gpio0 .
Access from userland is performed through
.Xr ioctl 2
calls on these devices.
.Sh IOCTL INTERFACE
The following structures and constants are defined in the
.Aq Pa sys/gpio.h
header file:
.Pp
.Bl -tag -width XXXX -compact
.It Dv GPIOINFO (struct gpio_info)
Returns information about the
.Tn GPIO
controller in the
.Fa gpio_info
structure:
.Bd -literal
struct gpio_info {
	int gpio_npins;		/* total number of pins available */
};
.Ed
.Pp
.It Dv GPIOPINREAD (struct gpio_pin_op)
Returns the input pin value in the
.Fa gpio_pin_op
structure:
.Bd -literal
struct gpio_pin_op {
	int gp_pin;		/* pin number */
	int gp_value;		/* value */
};
.Ed
.Pp
The
.Fa gp_pin
field must be set before calling.
.Pp
.It Dv GPIOPINWRITE (struct gpio_pin_op)
Writes the output value to the pin.
The value set in the
.Fa gp_value
field must be either
.Dv GPIO_PIN_LOW
(logical 0) or
.Dv GPIO_PIN_HIGH
(logical 1).
On return, the
.Fa gp_value
field contains the old pin state.
.Pp
.It Dv GPIOPINTOGGLE (struct gpio_pin_op)
Toggles the pin output value, i.e. changes it to the opposite.
.Fa gp_value
field is ignored and on return contains the old pin state.
.Pp
.It Dv GPIOPINCTL (struct gpio_pin_ctl)
Changes pin configuration flags with the new ones provided in the
.Fa gpio_pin_ctl
structure:
.Bd -literal
struct gpio_pin_ctl {
	int gp_pin;		/* pin number */
	int gp_caps;		/* pin capabilities (read-only) */
	int gp_flags;		/* pin configuration flags */
};
.Ed
.Pp
The
.Fa gp_flags
field is a combination of the following flags:
.Pp
.Bl -tag -width GPIO_PIN_OPENDRAIN -compact
.It Dv GPIO_PIN_INPUT
input direction
.It Dv GPIO_PIN_OUTPUT
output direction
.It Dv GPIO_PIN_INOUT
bi-directional
.It Dv GPIO_PIN_OPENDRAIN
open-drain output
.It Dv GPIO_PIN_PUSHPULL
push-pull output
.It Dv GPIO_PIN_TRISTATE
output disabled
.It Dv GPIO_PIN_PULLUP
internal pull-up enabled
.It Dv GPIO_PIN_PULLDOWN
internal pull-down enabled
.It Dv GPIO_PIN_INVIN
invert input
.It Dv GPIO_PIN_INVOUT
invert output
.El
.Pp
Note that the
.Tn GPIO
controller
may not support all of these flags.
On return the
.Fa gp_caps
field contains flags that are supported.
If no flags are specified, the pin configuration stays unchanged.
.El
.Sh FILES
.Bl -tag -width "/dev/gpiou" -compact
.It /dev/gpio Ns Ar u
GPIO device unit
.Ar u
file.
.El
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr gpioctl 8
.Sh HISTORY
The
.Nm
device first appeared in
.Ox 3.6
and
.Nx 4.0 .
.Sh AUTHORS
.An -nosplit
The
.Nm
driver was written by
.An Alexander Yurchenko Aq grange@openbsd.org .
.Nm
and was ported to
.Nx
by
.An Jared D. McNeill Aq jmcneill@NetBSD.org .
.Sh BUGS
Event capabilities are not supported.