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.\" 27*59c94aceSAndriy Gapon.Dd June 26, 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 75dbcb0e96SSean Bruno.Sh DESCRIPTION 76dbcb0e96SSean BrunoThe 775bd12c49SChristian Brueffer.Nm 788ce07fe7SLuiz Otavio O Souzasystem provides a simple interface to the GPIO pins that are usually 798ce07fe7SLuiz Otavio O Souzaavailable on embedded architectures and can provide bit banging style 808ce07fe7SLuiz Otavio O Souzadevices to the system. 81dbcb0e96SSean Bruno.Pp 82dbcb0e96SSean BrunoThe acronym 83dbcb0e96SSean Bruno.Li GPIO 84dbcb0e96SSean Brunomeans 85dbcb0e96SSean Bruno.Dq General-Purpose Input/Output. 86dbcb0e96SSean Bruno.Pp 87dbcb0e96SSean BrunoThe BUS physically consists of multiple pins that can be configured 88dbcb0e96SSean Brunofor input/output, IRQ delivery, SDA/SCL 89dbcb0e96SSean Bruno.Em iicbus 90dbcb0e96SSean Brunouse, etc. 918ce07fe7SLuiz Otavio O Souza.Pp 925bd12c49SChristian BruefferOn some embedded architectures (like MIPS), discovery of the bus and 93dbcb0e96SSean Brunoconfiguration of the pins is done via 94dbcb0e96SSean Bruno.Xr device.hints 5 95dbcb0e96SSean Brunoin the platform's kernel 96dbcb0e96SSean Bruno.Xr config 5 97dbcb0e96SSean Brunofile. 98dbcb0e96SSean Bruno.Pp 998ce07fe7SLuiz Otavio O SouzaOn some others (like ARM), where 1008ce07fe7SLuiz Otavio O Souza.Xr FDT 4 1018ce07fe7SLuiz Otavio O Souzais used to describe the device tree, the bus discovery is done via the DTS 1028ce07fe7SLuiz Otavio O Souzapassed to the kernel, being either statically compiled in, or by a variety 1038ce07fe7SLuiz Otavio O Souzaof ways where the boot loader (or Open Firmware enabled system) passes the 1045bd12c49SChristian BruefferDTS blob to the kernel at boot. 105dbcb0e96SSean Bruno.Pp 106*59c94aceSAndriy GaponOn a 107*59c94aceSAndriy Gapon.Xr device.hints 5 108*59c94aceSAndriy Gaponbased system these hints can be used to configure drivers for devices 109*59c94aceSAndriy Gaponattached to 110*59c94aceSAndriy Gapon.Nm 111*59c94aceSAndriy Gaponpins: 112*59c94aceSAndriy Gapon.Bl -tag -width ".Va hint.driver.unit.pins" 113*59c94aceSAndriy Gapon.It Va hint.driver.unit.at 114*59c94aceSAndriy GaponThe 115*59c94aceSAndriy Gapon.Nm gpiobus 116*59c94aceSAndriy Gaponwhere the device is attached. 117*59c94aceSAndriy GaponFor example, 118*59c94aceSAndriy Gapon.Qq gpiobus0 . 119*59c94aceSAndriy Gapon.Ar driver 120*59c94aceSAndriy Gaponand 121*59c94aceSAndriy Gapon.Ar unit 122*59c94aceSAndriy Gaponare the driver name and the unit number for the device driver. 123*59c94aceSAndriy Gapon.It Va hint.driver.unit.pins 124*59c94aceSAndriy GaponThis is a bitmask of the pins on the 125*59c94aceSAndriy Gapon.Nm gpiobus 126*59c94aceSAndriy Gaponthat are connected to the device. 127*59c94aceSAndriy GaponThe pins will be allocated to the specified driver instance. 128*59c94aceSAndriy Gapon.El 129*59c94aceSAndriy Gapon.Pp 1305bd12c49SChristian BruefferThe following 1315bd12c49SChristian Brueffer.Xr device.hints 5 1325bd12c49SChristian Bruefferare only provided by the 133dbcb0e96SSean Bruno.Cd ar71xx_gpio 1345bd12c49SChristian Bruefferdriver: 135*59c94aceSAndriy Gapon.Bl -tag -width ".Va hint.gpio.function_clear" 136dbcb0e96SSean Bruno.It Va hint.gpio.%d.pinmask 1375bd12c49SChristian BruefferThis is a bitmask of pins on the GPIO board that we would like to expose 1385bd12c49SChristian Bruefferfor use to the host operating system. 139dbcb0e96SSean BrunoTo expose pin 0, 4 and 7, use the bitmask of 140dbcb0e96SSean Bruno10010001 converted to the hexadecimal value 0x0091. 141dbcb0e96SSean Bruno.It Va hint.gpio.%d.pinon 1425bd12c49SChristian BruefferThis is a bitmask of pins on the GPIO board that will be set to ON at host 143dbcb0e96SSean Brunostart. 144dbcb0e96SSean BrunoTo set pin 2, 5 and 13 to be set ON at boot, use the bitmask of 145ff8b9505SSean Bruno10000000010010 converted to the hexadecimal value 0x2012. 146dbcb0e96SSean Bruno.It Va hint.gpio.function_set 147dbcb0e96SSean Bruno.It Va hint.gpio.function_clear 1485bd12c49SChristian BruefferThese are bitmasks of pins that will remap a pin to handle a specific 149dbcb0e96SSean Brunofunction (USB, UART TX/RX, etc) in the Atheros function registers. 150dbcb0e96SSean BrunoThis is mainly used to set/clear functions that we need when they are set up or 151dbcb0e96SSean Brunonot set up by uBoot. 152dbcb0e96SSean Bruno.El 153dbcb0e96SSean Bruno.Pp 154dbcb0e96SSean BrunoSimply put, each pin of the GPIO interface is connected to an input/output 155dbcb0e96SSean Brunoof some device in a system. 156dbcb0e96SSean Bruno.Sh SEE ALSO 1578ce07fe7SLuiz Otavio O Souza.Xr gpioiic 4 , 1588ce07fe7SLuiz Otavio O Souza.Xr gpioled 4 , 159dbcb0e96SSean Bruno.Xr iicbus 4 , 160*59c94aceSAndriy Gapon.Xr device.hints 5 , 161dbcb0e96SSean Bruno.Xr gpioctl 8 162dbcb0e96SSean Bruno.Sh HISTORY 163dbcb0e96SSean BrunoThe 164dbcb0e96SSean Bruno.Nm 165dbcb0e96SSean Brunomanual page first appeared in 166dbcb0e96SSean Bruno.Fx 10.0 . 167dbcb0e96SSean Bruno.Sh AUTHORS 168dbcb0e96SSean BrunoThis 169dbcb0e96SSean Brunomanual page was written by 1706c899950SBaptiste Daroussin.An Sean Bruno Aq Mt sbruno@FreeBSD.org . 171