Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

gpiobus(4) [freebsd man page]

GPIO(4) 						   BSD Kernel Interfaces Manual 						   GPIO(4)

gpiobus -- GPIO bus system SYNOPSIS
To compile these devices into your kernel and use the device hints, place the following lines in your kernel configuration file: device gpio device gpioc device gpioiic device gpioled Additional device entries for the ARM architecture include: 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 Additional device entries for the MIPS architecture include: device ar71xxx_gpio device octeon_gpio device rt305_gpio Additional device entries for the POWERPC architecture include: device wiigpio device macgpio DESCRIPTION
The gpiobus system provides a simple interface to the GPIO pins that are usually available on embedded architectures and can provide bit banging style devices to the system. The acronym GPIO means ``General-Purpose Input/Output.'' The BUS physically consists of multiple pins that can be configured for input/output, IRQ delivery, SDA/SCL iicbus use, etc. 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, being either statically compiled in, or by a variety of ways where the boot loader (or Open Firmware enabled system) passes the DTS blob to the kernel at boot. The following device.hints(5) are only provided by the ar71xx_gpio driver: 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 pin 0, 4 and 7, use the bitmask of 10010001 converted to the hexadecimal value 0x0091. 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 pin 2, 5 and 13 to be set ON at boot, use the bitmask of 10000000010010 converted to the hexadecimal value 0x2012. hint.gpio.function_set hint.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. Simply put, each pin of the GPIO interface is connected to an input/output of some device in a system. SEE ALSO
gpioiic(4), gpioled(4), iicbus(4), gpioctl(8) HISTORY
The gpiobus manual page first appeared in FreeBSD 10.0. AUTHORS
This manual page was written by Sean Bruno <>. BSD
November 5, 2013 BSD

Check Out this Related Man Page

GPIO(4) 						   BSD Kernel Interfaces Manual 						   GPIO(4)

gpio -- General Purpose Input/Output SYNOPSIS
gpio* at elansc? gpio* at epgpio? gpio* at gcscpcib? gpio* at gpiosim? gpio* at gscpcib? gpio* at ichlpcib? gpio* at nsclpcsio? gpio* at ppbus? #include <sys/types.h> #include <sys/gpio.h> #include <sys/ioctl.h> DESCRIPTION
The gpio device attaches to the GPIO controller and provides a uniform programming interface to its pins. Each GPIO controller with an attached gpio device has an associated device file under the /dev directory, e.g. /dev/gpio0. Access from user- land is performed through ioctl(2) calls on these devices. Whether the layout of the GPIO device can be configured is subject to authorization by the kauth(9) framework. If for example secmodel_securelevel(9) is active, the layout of the GPIO device is defined at a securelevel less than 1, i.e. typically dur- ing system boot, and cannot be changed later. GPIO pins can be configured and given a symbolic name and device drivers that use GPIO pins can be attached to the gpio device at a securelevel less than 1. All other pins will not be accessible once the runlevel has been raised. IOCTL INTERFACE
The following structures and constants are defined in the <sys/gpio.h> header file: GPIOINFO (struct gpio_info) Returns information about the GPIO controller in the gpio_info structure: struct gpio_info { int gpio_npins; /* total number of pins available */ }; GPIOREAD (struct gpio_req) Returns the input pin value in the gpio_pin_op structure: #define GPIOMAXNAME 64 struct gpio_req { char gp_name[GPIOMAXNAME]; /* pin name */ int gp_pin; /* pin number */ int gp_value; /* value */ }; The gp_name or gp_pin field must be set before calling. GPIOWRITE (struct gpio_req) Writes the output value to the pin. The value set in the gp_value field must be either GPIO_PIN_LOW (logical 0) or GPIO_PIN_HIGH (log- ical 1). On return, the gp_value field contains the old pin state. GPIOTOGGLE (struct gpio_req) Toggles the pin output value, i.e. changes it to the opposite. gp_value field is ignored and on return contains the old pin state. GPIOSET (struct gpio_set) Changes pin configuration flags with the new ones provided in the gpio_set structure: #define GPIOMAXNAME 64 struct gpio_set { char gp_name[GPIOMAXNAME]; /* pin name */ int gp_pin; /* pin number */ int gp_caps; /* pin capabilities (ro) */ int gp_flags; /* pin configuration flags */ char gp_name2[GPIOMAXNAME]; /* new name */ }; The gp_flags field is a combination of the following flags: GPIO_PIN_INPUT input direction GPIO_PIN_OUTPUT output direction GPIO_PIN_INOUT bi-directional GPIO_PIN_OPENDRAIN open-drain output GPIO_PIN_PUSHPULL push-pull output GPIO_PIN_TRISTATE output disabled GPIO_PIN_PULLUP internal pull-up enabled GPIO_PIN_PULLDOWN internal pull-down enabled GPIO_PIN_INVIN invert input GPIO_PIN_INVOUT invert output GPIO_PIN_PULSATE pulsate output Note that the GPIO controller may not support all of these flags. On return the gp_caps field contains flags that are supported. If no flags are specified, the pin configuration stays unchanged. Only GPIO pins that have been set using GPIOSET will be accessible at securelevels greater than 0. GPIOUNSET (struct gpio_set) Unset the specified pin, i.e. clear its name and make it unaccessible at securelevels greater than 0. GPIOATTACH (struct gpio_attach) Attach the device described in the gpio_attach structure on this gpio device. struct gpio_attach { char ga_dvname[16]; /* device name */ int ga_offset; /* pin number */ uint32_t ga_mask; /* binary mask */ uint32_t ga_flags; /* driver dependent */ }; The drvctl(8) command can be used to detach a device from a gpio pin. FILES
/dev/gpiou GPIO device unit u file. SEE ALSO
ioctl(2), drvctl(8), gpioctl(8) HISTORY
The gpio device first appeared in OpenBSD 3.6 and NetBSD 4.0. AUTHORS
The gpio driver was written by Alexander Yurchenko <>. gpio and was ported to NetBSD by Jared D. McNeill <>. Runtime device attachment was added by Marc Balmer <>. BUGS
Event capabilities are not supported. BSD
November 13, 2011 BSD
Man Page