---
name: "fdt_pinctrl"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/fdt_pinctrl/9"
---

# fdt\_pinctrl(9)

helper functions for FDT pinmux controller drivers

## NAME

**fdt\_pinctrl** – helper functions for FDT pinmux controller drivers

## SYNOPSIS

**#include \<dev/fdt/fdt\_pinctrl.h\>**

*int*\

**fdt\_pinctrl\_configure**(*device\_t client*, *u\_int index*);

*int*\

**fdt\_pinctrl\_configure\_by\_name**(*device\_t client*, *const char \* name*);

*int*\

**fdt\_pinctrl\_register**(*device\_t pinctrl*, *const char \*pinprop*);

*int*\

**fdt\_pinctrl\_configure\_tree**(*device\_t pinctrl*);

## DESCRIPTION

[fdt\_pinctrl(4)](/fdt_pinctrl/4.md) provides an API for manipulating I/O pin configurations on pinmux controllers and pinmux clients. On the controller side, the standard newbus probe and attach methods are implemented. As part of handling attach, it calls the **fdt\_pinctrl\_register**() function to register itself as a pinmux controller. Then **fdt\_pinctrl\_configure\_tree**() is used to walk the device tree and configure pins specified by the pinctrl-0 property for all active devices. The driver also implements the **fdt\_pinctrl\_configure**() method, which allows client devices to change their pin configurations after startup. If a client device requires a pin configuration change at some point of its lifecycle, it uses the **fdt\_pinctrl\_configure**() or **fdt\_pinctrl\_configure\_by\_name**() functions.

**fdt\_pinctrl\_configure**() is used by client device *client* to request a pin configuration described by the pinctrl-N property with index *index*.

**fdt\_pinctrl\_configure\_by\_name**() is used by client device *client* to request the pin configuration with name *name*.

**fdt\_pinctrl\_register**() registers a pinctrl driver so that it can be used by other devices which call **fdt\_pinctrl\_configure**() or **fdt\_pinctrl\_configure\_by\_name**(). It also registers each child node of the pinctrl driver's node which contains a property with the name given in *pinprop*. If *pinprop* is NULL, every descendant node is registered. It is possible for the driver to register itself as a pinmux controller for more than one pin property type by calling **fdt\_pinctrl\_register**() multiple types.

**fdt\_pinctrl\_configure\_tree**() walks through enabled devices in the device tree. If the pinctrl-0 property contains references to child nodes of the specified pinctrl device, their pins are configured.

## EXAMPLES

```
static int
foo_configure_pins(device_t dev, phandle_t cfgxref)
{
	phandle_t cfgnode;
	uint32_t *pins, *functions;
	int npins, nfunctions;
	cfgnode = OF_node_from_xref(cfgxref);
	pins = NULL;
	npins = OF_getencprop_alloc_multi(cfgnode, "foo,pins", sizeof(*pins),
	    (void **)&pins);
	functions = NULL;
	nfunctions = OF_getencprop_alloc_multi(cfgnode, "foo,functions",
	    sizeof(*functions), (void **)&functions);
	...
}
static int
foo_is_gpio(device_t dev, device_t gpiodev, bool *is_gpio)
{
	return (foo_is_pin_func_gpio(is_gpio));
}
static int
foo_set_flags(device_t dev, device_t gpiodev, uint32_t pin, uint32_t flags)
{
	int rv;
	rv = foo_is_pin_func_gpio(is_gpio);
	if (rv != 0)
		return (rv);
	foo_set_flags(pin, flags);
	return (0);
}
static int
foo_get_flags(device_t dev, device_t gpiodev, uint32_t pin, uint32_t *flags)
{
	int rv;
	rv = foo_is_pin_func_gpio(is_gpio);
	if (rv != 0)
		return (rv);
	foo_get_flags(pin, flags);
	return (0);
}
static int
foo_attach(device_t dev)
{
	...
	fdt_pinctrl_register(dev, "foo,pins");
	/*
	 * It is possible to register more than one pinprop handler
	 */
	fdt_pinctrl_register(dev, "bar,pins");
	fdt_pinctrl_configure_tree(dev);
	return (0);
}
static device_method_t foo_methods[] = {
	...
	/* fdt_pinctrl interface */
	DEVMETHOD(fdt_pinctrl_configure, foo_configure_pins),
	DEVMETHOD(fdt_pinctrl_is_gpio, foo_is_gpio),
	DEVMETHOD(fdt_pinctrl_set_flags, foo_set_flags),
	DEVMETHOD(fdt_pinctrl_get_flags, foo_get_flags),
	/* Terminate method list */
	DEVMETHOD_END
};
DRIVER_MODULE(foo, simplebus, foo_driver, foo_devclass, NULL, NULL);
```

## SEE ALSO

[fdt\_pinctrl(4)](/fdt_pinctrl/4.md)

## AUTHORS

This manual page was written by Oleksandr Tymoshenko.
