xref: /freebsd/share/man/man4/gpio.4 (revision 5668a155cbe6cef802bc95666477a440fdb6f606)
1dbcb0e96SSean Bruno.\" Copyright (c) 2013, Sean Bruno <sbruno@freebsd.org>
2dbcb0e96SSean Bruno.\" All rights reserved.
3dbcb0e96SSean Bruno.\"
4dbcb0e96SSean Bruno.\" Redistribution and use in source and binary forms, with or without
5dbcb0e96SSean Bruno.\" modification, are permitted provided that the following conditions
6dbcb0e96SSean Bruno.\" are met:
7dbcb0e96SSean Bruno.\" 1. Redistributions of source code must retain the above copyright
8dbcb0e96SSean Bruno.\"    notice, this list of conditions and the following disclaimer.
9dbcb0e96SSean Bruno.\" 2. Redistributions in binary form must reproduce the above copyright
10dbcb0e96SSean Bruno.\"    notice, this list of conditions and the following disclaimer in the
11dbcb0e96SSean Bruno.\"    documentation and/or other materials provided with the distribution.
12dbcb0e96SSean Bruno.\"
13dbcb0e96SSean Bruno.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14dbcb0e96SSean Bruno.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15dbcb0e96SSean Bruno.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16dbcb0e96SSean Bruno.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17dbcb0e96SSean Bruno.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18dbcb0e96SSean Bruno.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19dbcb0e96SSean Bruno.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20dbcb0e96SSean Bruno.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21dbcb0e96SSean Bruno.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22dbcb0e96SSean Bruno.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23dbcb0e96SSean Bruno.\" SUCH DAMAGE.
24dbcb0e96SSean Bruno.\"
25dbcb0e96SSean Bruno.\" $FreeBSD$
26dbcb0e96SSean Bruno.\"
27061b38cdSAndriy Gapon.Dd June 27, 2019
28dbcb0e96SSean Bruno.Dt GPIO 4
29dbcb0e96SSean Bruno.Os
30dbcb0e96SSean Bruno.Sh NAME
31dbcb0e96SSean Bruno.Nm gpiobus
32dbcb0e96SSean Bruno.Nd GPIO bus system
33dbcb0e96SSean Bruno.Sh SYNOPSIS
34dbcb0e96SSean BrunoTo compile these devices into your kernel and use the device hints, place the
35dbcb0e96SSean Brunofollowing lines in your kernel configuration file:
36dbcb0e96SSean Bruno.Bd -ragged -offset indent
37dbcb0e96SSean Bruno.Cd "device gpio"
38dbcb0e96SSean Bruno.Cd "device gpioc"
398ce07fe7SLuiz Otavio O Souza.Cd "device gpioiic"
40dbcb0e96SSean Bruno.Cd "device gpioled"
41dbcb0e96SSean Bruno.Ed
42dbcb0e96SSean Bruno.Pp
43dbcb0e96SSean BrunoAdditional device entries for the
44dbcb0e96SSean Bruno.Li ARM
455bd12c49SChristian Bruefferarchitecture include:
46dbcb0e96SSean Bruno.Bd -ragged -offset indent
47dbcb0e96SSean Bruno.Cd "device a10_gpio"
48dbcb0e96SSean Bruno.Cd "device bcm_gpio"
49dbcb0e96SSean Bruno.Cd "device imx51_gpio"
50dbcb0e96SSean Bruno.Cd "device lpcgpio"
51dbcb0e96SSean Bruno.Cd "device mv_gpio"
52dbcb0e96SSean Bruno.Cd "device ti_gpio"
53dbcb0e96SSean Bruno.Cd "device gpio_avila"
54dbcb0e96SSean Bruno.Cd "device gpio_cambria"
55dbcb0e96SSean Bruno.Cd "device zy7_gpio"
56dbcb0e96SSean Bruno.Cd "device pxagpio"
57dbcb0e96SSean Bruno.Ed
58dbcb0e96SSean Bruno.Pp
59dbcb0e96SSean BrunoAdditional device entries for the
60dbcb0e96SSean Bruno.Li MIPS
615bd12c49SChristian Bruefferarchitecture include:
62dbcb0e96SSean Bruno.Bd -ragged -offset indent
63dbcb0e96SSean Bruno.Cd "device ar71xxx_gpio"
64dbcb0e96SSean Bruno.Cd "device octeon_gpio"
65dbcb0e96SSean Bruno.Cd "device rt305_gpio"
66dbcb0e96SSean Bruno.Ed
67dbcb0e96SSean Bruno.Pp
68dbcb0e96SSean BrunoAdditional device entries for the
69dbcb0e96SSean Bruno.Li POWERPC
705bd12c49SChristian Bruefferarchitecture include:
71dbcb0e96SSean Bruno.Bd -ragged -offset indent
72dbcb0e96SSean Bruno.Cd "device wiigpio"
73dbcb0e96SSean Bruno.Cd "device macgpio"
74dbcb0e96SSean Bruno.Ed
75*5668a155SJessica Clarke.Pp
76*5668a155SJessica ClarkeAdditional device entries for the
77*5668a155SJessica Clarke.Li RISC-V
78*5668a155SJessica Clarkearchitecture include:
79*5668a155SJessica Clarke.Bd -ragged -offset indent
80*5668a155SJessica Clarke.Cd "device sifive_gpio"
81*5668a155SJessica Clarke.Ed
82dbcb0e96SSean Bruno.Sh DESCRIPTION
83dbcb0e96SSean BrunoThe
845bd12c49SChristian Brueffer.Nm
858ce07fe7SLuiz Otavio O Souzasystem provides a simple interface to the GPIO pins that are usually
868ce07fe7SLuiz Otavio O Souzaavailable on embedded architectures and can provide bit banging style
878ce07fe7SLuiz Otavio O Souzadevices to the system.
88dbcb0e96SSean Bruno.Pp
89dbcb0e96SSean BrunoThe acronym
90dbcb0e96SSean Bruno.Li GPIO
91dbcb0e96SSean Brunomeans
92dbcb0e96SSean Bruno.Dq General-Purpose Input/Output.
93dbcb0e96SSean Bruno.Pp
94dbcb0e96SSean BrunoThe BUS physically consists of multiple pins that can be configured
95dbcb0e96SSean Brunofor input/output, IRQ delivery, SDA/SCL
96dbcb0e96SSean Bruno.Em iicbus
97dbcb0e96SSean Brunouse, etc.
988ce07fe7SLuiz Otavio O Souza.Pp
995bd12c49SChristian BruefferOn some embedded architectures (like MIPS), discovery of the bus and
100dbcb0e96SSean Brunoconfiguration of the pins is done via
101dbcb0e96SSean Bruno.Xr device.hints 5
102dbcb0e96SSean Brunoin the platform's kernel
103dbcb0e96SSean Bruno.Xr config 5
104dbcb0e96SSean Brunofile.
105dbcb0e96SSean Bruno.Pp
1068ce07fe7SLuiz Otavio O SouzaOn some others (like ARM), where
1078ce07fe7SLuiz Otavio O Souza.Xr FDT 4
1088ce07fe7SLuiz Otavio O Souzais used to describe the device tree, the bus discovery is done via the DTS
1098ce07fe7SLuiz Otavio O Souzapassed to the kernel, being either statically compiled in, or by a variety
1108ce07fe7SLuiz Otavio O Souzaof ways where the boot loader (or Open Firmware enabled system) passes the
1115bd12c49SChristian BruefferDTS blob to the kernel at boot.
112dbcb0e96SSean Bruno.Pp
11359c94aceSAndriy GaponOn a
11459c94aceSAndriy Gapon.Xr device.hints 5
11559c94aceSAndriy Gaponbased system these hints can be used to configure drivers for devices
11659c94aceSAndriy Gaponattached to
11759c94aceSAndriy Gapon.Nm
11859c94aceSAndriy Gaponpins:
119061b38cdSAndriy Gapon.Bl -tag -width ".Va hint.driver.unit.pin_list"
12059c94aceSAndriy Gapon.It Va hint.driver.unit.at
12159c94aceSAndriy GaponThe
12259c94aceSAndriy Gapon.Nm gpiobus
12359c94aceSAndriy Gaponwhere the device is attached.
12459c94aceSAndriy GaponFor example,
12559c94aceSAndriy Gapon.Qq gpiobus0 .
12659c94aceSAndriy Gapon.Ar driver
12759c94aceSAndriy Gaponand
12859c94aceSAndriy Gapon.Ar unit
12959c94aceSAndriy Gaponare the driver name and the unit number for the device driver.
13059c94aceSAndriy Gapon.It Va hint.driver.unit.pins
13159c94aceSAndriy GaponThis is a bitmask of the pins on the
13259c94aceSAndriy Gapon.Nm gpiobus
13359c94aceSAndriy Gaponthat are connected to the device.
13459c94aceSAndriy GaponThe pins will be allocated to the specified driver instance.
135061b38cdSAndriy GaponOnly pins with numbers from 0 to 31 can be specified using this hint.
136061b38cdSAndriy Gapon.It Va hint.driver.unit.pin_list
137061b38cdSAndriy GaponThis is a list of pin numbers of pins on the
138061b38cdSAndriy Gapon.Nm gpiobus
139061b38cdSAndriy Gaponthat are connected to the device.
140061b38cdSAndriy GaponThe pins will be allocated to the specified driver instance.
141061b38cdSAndriy GaponThis is a more user friendly alternative to the
142061b38cdSAndriy Gapon.Ar pins
143061b38cdSAndriy Gaponhint.
144061b38cdSAndriy GaponAdditionally, this hint allows specifying pin numbers greater than 31.
145061b38cdSAndriy GaponThe numbers can be decimal or hexadecimal with 0x prefix.
146061b38cdSAndriy GaponAny non-digit character can be used as a separator.
147061b38cdSAndriy GaponFor example, it can be a comma, a slash or a space.
148061b38cdSAndriy GaponThe separator can be followed by any number of space characters.
14959c94aceSAndriy Gapon.El
15059c94aceSAndriy Gapon.Pp
1515bd12c49SChristian BruefferThe following
1525bd12c49SChristian Brueffer.Xr device.hints 5
1535bd12c49SChristian Bruefferare only provided by the
154dbcb0e96SSean Bruno.Cd ar71xx_gpio
1555bd12c49SChristian Bruefferdriver:
15659c94aceSAndriy Gapon.Bl -tag -width ".Va hint.gpio.function_clear"
157dbcb0e96SSean Bruno.It Va hint.gpio.%d.pinmask
1585bd12c49SChristian BruefferThis is a bitmask of pins on the GPIO board that we would like to expose
1595bd12c49SChristian Bruefferfor use to the host operating system.
160dbcb0e96SSean BrunoTo expose pin 0, 4 and 7, use the bitmask of
161dbcb0e96SSean Bruno10010001 converted to the hexadecimal value 0x0091.
162dbcb0e96SSean Bruno.It Va hint.gpio.%d.pinon
1635bd12c49SChristian BruefferThis is a bitmask of pins on the GPIO board that will be set to ON at host
164dbcb0e96SSean Brunostart.
165dbcb0e96SSean BrunoTo set pin 2, 5 and 13 to be set ON at boot, use the bitmask of
166ff8b9505SSean Bruno10000000010010 converted to the hexadecimal value 0x2012.
167dbcb0e96SSean Bruno.It Va hint.gpio.function_set
168dbcb0e96SSean Bruno.It Va hint.gpio.function_clear
1695bd12c49SChristian BruefferThese are bitmasks of pins that will remap a pin to handle a specific
170dbcb0e96SSean Brunofunction (USB, UART TX/RX, etc) in the Atheros function registers.
171dbcb0e96SSean BrunoThis is mainly used to set/clear functions that we need when they are set up or
172dbcb0e96SSean Brunonot set up by uBoot.
173dbcb0e96SSean Bruno.El
174dbcb0e96SSean Bruno.Pp
175dbcb0e96SSean BrunoSimply put, each pin of the GPIO interface is connected to an input/output
176dbcb0e96SSean Brunoof some device in a system.
177dbcb0e96SSean Bruno.Sh SEE ALSO
1788ce07fe7SLuiz Otavio O Souza.Xr gpioiic 4 ,
1798ce07fe7SLuiz Otavio O Souza.Xr gpioled 4 ,
180dbcb0e96SSean Bruno.Xr iicbus 4 ,
18159c94aceSAndriy Gapon.Xr device.hints 5 ,
182dbcb0e96SSean Bruno.Xr gpioctl 8
183dbcb0e96SSean Bruno.Sh HISTORY
184dbcb0e96SSean BrunoThe
185dbcb0e96SSean Bruno.Nm
186dbcb0e96SSean Brunomanual page first appeared in
187dbcb0e96SSean Bruno.Fx 10.0 .
188dbcb0e96SSean Bruno.Sh AUTHORS
189dbcb0e96SSean BrunoThis
190dbcb0e96SSean Brunomanual page was written by
1916c899950SBaptiste Daroussin.An Sean Bruno Aq Mt sbruno@FreeBSD.org .
192