GPIO(4)
๐ GPIO(4) โ the gpiobus situation, explained
okay bestie, welcome to GPIO(4), straight out of the Kernel Interfaces Manual โจ this is the whole gpiobus โ GPIO bus system โ and honestly it's giving "tiny pins, big main character energy" ๐ฅ
๐ธ SYNOPSIS
so like, if you wanna compile these devices into your kernel and use the device hints, you gotta put these lines in your kernel configuration file, no cap:
device gpio
device gpioiic
device gpioled
and then โ plot twist โ there are extra device entries depending on your architecture. we love a per-platform moment ๐
For the ARM architecture, add:
device a10_gpio
device bcm_gpio
device imx51_gpio
device lpcgpio
device mv_gpio
device ti_gpio
device gpio_avila
device gpio_cambria
device zy7_gpio
device pxagpio
For the MIPS architecture, add:
device ar71xxx_gpio
device octeon_gpio
device rt305_gpio
For the POWERPC architecture, add:
device wiigpio
device macgpio
For the RISC-V architecture, add:
device sifive_gpio
like yes, they really did make a whole roster ๐ซถ
๐ฆ DESCRIPTION
so the gpiobus system hands you a simple interface to the GPIO pins โ the ones that are usually hanging out on embedded architectures โ and it can also give the system bit banging style devices. icon behavior honestly โจ
the acronym GPIO means โGeneral-Purpose Input/Output.โ periodt ๐
the BUS physically consists of multiple pins that can be configured for input/output, IRQ delivery, SDA/SCL iicbus use, etc. like little multitaskers ๐
on some embedded architectures (like MIPS), discovery of the bus and configuration of the pins is done via device.hints(5) in the platform's kernel config(5) file.
on some others (like ARM), where FDT(4) is used to describe the device tree, the bus discovery is done via the DTS passed to the kernel โ and that can be either statically compiled in, or handled by a variety of ways where the boot loader (or an Open Firmware enabled system) passes the DTS blob to the kernel at boot. very "it depends" of it ๐ญ
๐ง the device.hints(5) hints
on a device.hints(5) based system, these hints can be used to configure drivers for devices attached to gpiobus pins:
hint.driver.unit.atโ thegpiobuswhere the device is attached. for example,"gpiobus0".driverandunitare the driver name and the unit number for the device driver. iykyk ๐ธhint.driver.unit.pinsโ this is a bitmask of the pins on thegpiobusthat are connected to the device. the pins will be allocated to the specified driver instance. heads up bestie: only pins with numbers from0to31can be specified using this hint ๐ซถhint.driver.unit.pin_listโ this is a list of pin numbers of pins on thegpiobusthat are connected to the device. the pins will be allocated to the specified driver instance. this is a more user friendly alternative to thepinshint. additionally, this hint allows specifying pin numbers greater than31๐ the numbers can be decimal or hexadecimal with0xprefix. any non-digit character can be used as a separator โ for example, it can be a comma, a slash or a space. the separator can be followed by any number of space characters. literally so flexible, ate ๐
๐ the ar71xx_gpio-only hints
the following device.hints(5) are only provided by the ar71xx_gpio driver โ exclusive fr fr:
hint.gpio.%d.pinmaskโ this is a bitmask of pins on the GPIO board that we would like to expose for use to the host operating system. to expose pin0,4and7, use the bitmask of10010001converted to the hexadecimal value0x0091. math queen behavior ๐งฎhint.gpio.%d.pinonโ this is a bitmask of pins on the GPIO board that will be set to ON at host start. to set pin2,5and13to be set ON at boot, use the bitmask of10000000010010converted to the hexadecimal value0x2012โจhint.gpio.function_sethint.gpio.function_clearโ these are bitmasks of pins that will remap a pin to handle a specific function (USB, UART TX/RX, etc) in the Atheros function registers. this is mainly used to set/clear functions that we need when they are set up or not set up by uBoot.
and simply put โ each pin of the GPIO interface is connected to an input/output of some device in a system. that's the whole vibe ๐
๐ฅ SEE ALSO
gpioiic(4), gpioled(4), iicbus(4), device.hints(5), gpioctl(8)
go read those too, bestie, they're all linked ๐ซถ
๐ HISTORY
the gpiobus manual page first appeared in FreeBSD 10.0. a classic, honestly โญ
๐ AUTHORS
this manual page was written by Sean Bruno <sbruno@FreeBSD.org>. thank you for your service ๐ซก๐
ok that's the whole page, no gatekeeping here ๐ go forth and configure those pins, bestie ๐ฆ
โ Debian, August 28, 2025 โ GPIO(4) โ that's a wrap, mwah ๐โจ
๐ฆ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- ๐ the page's license: BSD-2-Clause
- Copyright (c) 2013, Sean Bruno <sbruno@freebsd.org>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms