xref: /freebsd/share/man/man4/gpio.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
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.\"
25061b38cdSAndriy Gapon.Dd June 27, 2019
26dbcb0e96SSean Bruno.Dt GPIO 4
27dbcb0e96SSean Bruno.Os
28dbcb0e96SSean Bruno.Sh NAME
29dbcb0e96SSean Bruno.Nm gpiobus
30dbcb0e96SSean Bruno.Nd GPIO bus system
31dbcb0e96SSean Bruno.Sh SYNOPSIS
32dbcb0e96SSean BrunoTo compile these devices into your kernel and use the device hints, place the
33dbcb0e96SSean Brunofollowing lines in your kernel configuration file:
34dbcb0e96SSean Bruno.Bd -ragged -offset indent
35dbcb0e96SSean Bruno.Cd "device gpio"
36dbcb0e96SSean Bruno.Cd "device gpioc"
378ce07fe7SLuiz Otavio O Souza.Cd "device gpioiic"
38dbcb0e96SSean Bruno.Cd "device gpioled"
39dbcb0e96SSean Bruno.Ed
40dbcb0e96SSean Bruno.Pp
41dbcb0e96SSean BrunoAdditional device entries for the
42dbcb0e96SSean Bruno.Li ARM
435bd12c49SChristian Bruefferarchitecture include:
44dbcb0e96SSean Bruno.Bd -ragged -offset indent
45dbcb0e96SSean Bruno.Cd "device a10_gpio"
46dbcb0e96SSean Bruno.Cd "device bcm_gpio"
47dbcb0e96SSean Bruno.Cd "device imx51_gpio"
48dbcb0e96SSean Bruno.Cd "device lpcgpio"
49dbcb0e96SSean Bruno.Cd "device mv_gpio"
50dbcb0e96SSean Bruno.Cd "device ti_gpio"
51dbcb0e96SSean Bruno.Cd "device gpio_avila"
52dbcb0e96SSean Bruno.Cd "device gpio_cambria"
53dbcb0e96SSean Bruno.Cd "device zy7_gpio"
54dbcb0e96SSean Bruno.Cd "device pxagpio"
55dbcb0e96SSean Bruno.Ed
56dbcb0e96SSean Bruno.Pp
57dbcb0e96SSean BrunoAdditional device entries for the
58dbcb0e96SSean Bruno.Li MIPS
595bd12c49SChristian Bruefferarchitecture include:
60dbcb0e96SSean Bruno.Bd -ragged -offset indent
61dbcb0e96SSean Bruno.Cd "device ar71xxx_gpio"
62dbcb0e96SSean Bruno.Cd "device octeon_gpio"
63dbcb0e96SSean Bruno.Cd "device rt305_gpio"
64dbcb0e96SSean Bruno.Ed
65dbcb0e96SSean Bruno.Pp
66dbcb0e96SSean BrunoAdditional device entries for the
67dbcb0e96SSean Bruno.Li POWERPC
685bd12c49SChristian Bruefferarchitecture include:
69dbcb0e96SSean Bruno.Bd -ragged -offset indent
70dbcb0e96SSean Bruno.Cd "device wiigpio"
71dbcb0e96SSean Bruno.Cd "device macgpio"
72dbcb0e96SSean Bruno.Ed
73*5668a155SJessica Clarke.Pp
74*5668a155SJessica ClarkeAdditional device entries for the
75*5668a155SJessica Clarke.Li RISC-V
76*5668a155SJessica Clarkearchitecture include:
77*5668a155SJessica Clarke.Bd -ragged -offset indent
78*5668a155SJessica Clarke.Cd "device sifive_gpio"
79*5668a155SJessica Clarke.Ed
80dbcb0e96SSean Bruno.Sh DESCRIPTION
81dbcb0e96SSean BrunoThe
825bd12c49SChristian Brueffer.Nm
838ce07fe7SLuiz Otavio O Souzasystem provides a simple interface to the GPIO pins that are usually
848ce07fe7SLuiz Otavio O Souzaavailable on embedded architectures and can provide bit banging style
858ce07fe7SLuiz Otavio O Souzadevices to the system.
86dbcb0e96SSean Bruno.Pp
87dbcb0e96SSean BrunoThe acronym
88dbcb0e96SSean Bruno.Li GPIO
89dbcb0e96SSean Brunomeans
90dbcb0e96SSean Bruno.Dq General-Purpose Input/Output.
91dbcb0e96SSean Bruno.Pp
92dbcb0e96SSean BrunoThe BUS physically consists of multiple pins that can be configured
93dbcb0e96SSean Brunofor input/output, IRQ delivery, SDA/SCL
94dbcb0e96SSean Bruno.Em iicbus
95dbcb0e96SSean Brunouse, etc.
968ce07fe7SLuiz Otavio O Souza.Pp
975bd12c49SChristian BruefferOn some embedded architectures (like MIPS), discovery of the bus and
98dbcb0e96SSean Brunoconfiguration of the pins is done via
99dbcb0e96SSean Bruno.Xr device.hints 5
100dbcb0e96SSean Brunoin the platform's kernel
101dbcb0e96SSean Bruno.Xr config 5
102dbcb0e96SSean Brunofile.
103dbcb0e96SSean Bruno.Pp
1048ce07fe7SLuiz Otavio O SouzaOn some others (like ARM), where
1058ce07fe7SLuiz Otavio O Souza.Xr FDT 4
1068ce07fe7SLuiz Otavio O Souzais used to describe the device tree, the bus discovery is done via the DTS
1078ce07fe7SLuiz Otavio O Souzapassed to the kernel, being either statically compiled in, or by a variety
1088ce07fe7SLuiz Otavio O Souzaof ways where the boot loader (or Open Firmware enabled system) passes the
1095bd12c49SChristian BruefferDTS blob to the kernel at boot.
110dbcb0e96SSean Bruno.Pp
11159c94aceSAndriy GaponOn a
11259c94aceSAndriy Gapon.Xr device.hints 5
11359c94aceSAndriy Gaponbased system these hints can be used to configure drivers for devices
11459c94aceSAndriy Gaponattached to
11559c94aceSAndriy Gapon.Nm
11659c94aceSAndriy Gaponpins:
117061b38cdSAndriy Gapon.Bl -tag -width ".Va hint.driver.unit.pin_list"
11859c94aceSAndriy Gapon.It Va hint.driver.unit.at
11959c94aceSAndriy GaponThe
12059c94aceSAndriy Gapon.Nm gpiobus
12159c94aceSAndriy Gaponwhere the device is attached.
12259c94aceSAndriy GaponFor example,
12359c94aceSAndriy Gapon.Qq gpiobus0 .
12459c94aceSAndriy Gapon.Ar driver
12559c94aceSAndriy Gaponand
12659c94aceSAndriy Gapon.Ar unit
12759c94aceSAndriy Gaponare the driver name and the unit number for the device driver.
12859c94aceSAndriy Gapon.It Va hint.driver.unit.pins
12959c94aceSAndriy GaponThis is a bitmask of the pins on the
13059c94aceSAndriy Gapon.Nm gpiobus
13159c94aceSAndriy Gaponthat are connected to the device.
13259c94aceSAndriy GaponThe pins will be allocated to the specified driver instance.
133061b38cdSAndriy GaponOnly pins with numbers from 0 to 31 can be specified using this hint.
134061b38cdSAndriy Gapon.It Va hint.driver.unit.pin_list
135061b38cdSAndriy GaponThis is a list of pin numbers of pins on the
136061b38cdSAndriy Gapon.Nm gpiobus
137061b38cdSAndriy Gaponthat are connected to the device.
138061b38cdSAndriy GaponThe pins will be allocated to the specified driver instance.
139061b38cdSAndriy GaponThis is a more user friendly alternative to the
140061b38cdSAndriy Gapon.Ar pins
141061b38cdSAndriy Gaponhint.
142061b38cdSAndriy GaponAdditionally, this hint allows specifying pin numbers greater than 31.
143061b38cdSAndriy GaponThe numbers can be decimal or hexadecimal with 0x prefix.
144061b38cdSAndriy GaponAny non-digit character can be used as a separator.
145061b38cdSAndriy GaponFor example, it can be a comma, a slash or a space.
146061b38cdSAndriy GaponThe separator can be followed by any number of space characters.
14759c94aceSAndriy Gapon.El
14859c94aceSAndriy Gapon.Pp
1495bd12c49SChristian BruefferThe following
1505bd12c49SChristian Brueffer.Xr device.hints 5
1515bd12c49SChristian Bruefferare only provided by the
152dbcb0e96SSean Bruno.Cd ar71xx_gpio
1535bd12c49SChristian Bruefferdriver:
15459c94aceSAndriy Gapon.Bl -tag -width ".Va hint.gpio.function_clear"
155dbcb0e96SSean Bruno.It Va hint.gpio.%d.pinmask
1565bd12c49SChristian BruefferThis is a bitmask of pins on the GPIO board that we would like to expose
1575bd12c49SChristian Bruefferfor use to the host operating system.
158dbcb0e96SSean BrunoTo expose pin 0, 4 and 7, use the bitmask of
159dbcb0e96SSean Bruno10010001 converted to the hexadecimal value 0x0091.
160dbcb0e96SSean Bruno.It Va hint.gpio.%d.pinon
1615bd12c49SChristian BruefferThis is a bitmask of pins on the GPIO board that will be set to ON at host
162dbcb0e96SSean Brunostart.
163dbcb0e96SSean BrunoTo set pin 2, 5 and 13 to be set ON at boot, use the bitmask of
164ff8b9505SSean Bruno10000000010010 converted to the hexadecimal value 0x2012.
165dbcb0e96SSean Bruno.It Va hint.gpio.function_set
166dbcb0e96SSean Bruno.It Va hint.gpio.function_clear
1675bd12c49SChristian BruefferThese are bitmasks of pins that will remap a pin to handle a specific
168dbcb0e96SSean Brunofunction (USB, UART TX/RX, etc) in the Atheros function registers.
169dbcb0e96SSean BrunoThis is mainly used to set/clear functions that we need when they are set up or
170dbcb0e96SSean Brunonot set up by uBoot.
171dbcb0e96SSean Bruno.El
172dbcb0e96SSean Bruno.Pp
173dbcb0e96SSean BrunoSimply put, each pin of the GPIO interface is connected to an input/output
174dbcb0e96SSean Brunoof some device in a system.
175dbcb0e96SSean Bruno.Sh SEE ALSO
1768ce07fe7SLuiz Otavio O Souza.Xr gpioiic 4 ,
1778ce07fe7SLuiz Otavio O Souza.Xr gpioled 4 ,
178dbcb0e96SSean Bruno.Xr iicbus 4 ,
17959c94aceSAndriy Gapon.Xr device.hints 5 ,
180dbcb0e96SSean Bruno.Xr gpioctl 8
181dbcb0e96SSean Bruno.Sh HISTORY
182dbcb0e96SSean BrunoThe
183dbcb0e96SSean Bruno.Nm
184dbcb0e96SSean Brunomanual page first appeared in
185dbcb0e96SSean Bruno.Fx 10.0 .
186dbcb0e96SSean Bruno.Sh AUTHORS
187dbcb0e96SSean BrunoThis
188dbcb0e96SSean Brunomanual page was written by
1896c899950SBaptiste Daroussin.An Sean Bruno Aq Mt sbruno@FreeBSD.org .
190