GPIOIIC(4)
π GPIOIIC(4) π
okay bestie, so this one's a gpioiic man page β it's the GPIO I2C bit-banging device driver and honestly it's giving main character energy for your embedded projects β¨
π SYNOPSIS π
so if you wanna bake this driver right into your kernel, drop these lines in your kernel configuration file fr fr:
device gpio
device gpioiic
device iicbb
device iicbus
or, if you'd rather just load it as a module at boot time (lowkey the easier vibe), put this line in loader.conf(5):
gpioiic_load="YES"
β¨ DESCRIPTION β¨
okay so the gpioiic driver is out here giving you an IIC bit-banging interface using just two GPIO pins for the SCL and SDA lines on the bus. iconic behavior honestly π¦
here's the tea though: gpioiic simulates an open collector kind of output when it's managing the pins on the bus β even on systems that don't directly support configuring gpio pins in that mode. and like, it's very mindful about it: the pins are never driven to the logical value of '1'. nope. they get driven to '0' or switched to input mode (Hi-Z/tri-state), and then an external pullup resistor pulls the line to the 1 state β unless some other device on the bus is out here driving it to 0. teamwork makes the dream work π
πΈ HINTS CONFIGURATION πΈ
on a device.hints(5) based system (like MIPS), these values are configurable for gpioiic:
hint.gpioiic.%d.atβ thegpiobusyou're attaching to. normally it's justgpiobus0on systems with a single bank of gpio pins.hint.gpioiic.%d.pinsβ this is a bitmask of the pins on thegpiobusthat get used for SCLOCK and SDATA from the GPIO IIC bit-banging bus. so to configure pin 0 and 7, you use the bitmask of0b10000001and convert it to a hexadecimal value of0x0081. also β οΈ please note this mask should only ever have two bits set (any other bits β i.e. pins β will just be ignored). and becausegpioiicmust be a child of thegpiobus, both gpio pins must be part of that bus. no exceptions bestie.hint.gpioiic.%d.sclβ indicates which bit in thehint.gpioiic.%d.pinsshould be used as the SCLOCK source. it's optional and defaults to0.hint.gpioiic.%d.sdaβ indicates which bit in thehint.gpioiic.%d.pinsshould be used as the SDATA source. also optional, defaults to1.
π¦ FDT CONFIGURATION π¦
on an FDT(4) based system (like ARM), the DTS node for gpioiic conforms to the standard bindings document i2c/i2c-gpio.yaml. the device node typically appears at the root of the device tree. here's an example of a gpioiic node with one slave device on the IIC bus:
/ {
gpioiic0 {
compatible = "i2c-gpio";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpioiic0>;
scl-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
sda-gpios = <&gpio7 11 GPIO_ACTIVE_HIGH>;
status = "okay";
/* One slave device on the i2c bus. */
rtc@51 {
compatible="nxp,pcf2127";
reg = <0x51>;
status = "okay";
};
};
};
so what's what:
compatibleβ should be set to"i2c-gpio". but heads up: the deprecated string"gpioiic"is also accepted for backwards compatibility. we love a nostalgic moment πscl-gpios/sda-gpiosβ these properties indicate which GPIO pins should be used for clock and data on the GPIO IIC bit-banging bus. and like, there's no requirement that the two pins belong to the same gpio controller. they can be from totally different friend groups, it's fine π«Άpinctrl-names/pinctrl-0β these properties may be required to configure the chosen pins as gpio pins, unless the pins already default to that state on your system. iykyk.
π SEE ALSO π
fdt(4), gpio(4), iic(4), iicbb(4), iicbus(4)
β HISTORY β
the gpioiic manual page first appeared in FreeBSD 10.1. a whole era π
π AUTHORS π
this manual page was written by Luiz Otavio O Souza. respect the icon who wrote it π
alright bestie, that's the whole page! this version is from Debian, dated December 1, 2019 β and honestly the Debian folks ate with this one. now go forth and bit-bang responsibly π§β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2013, Luiz Otavio O Souza <loos@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms