Struct gpio_cdev::Chip[][src]

pub struct Chip { /* fields omitted */ }

A GPIO Chip maps to the actual device driver instance in hardware that one interacts with to interact with individual GPIOs. Often these chips map to IP chunks on an SoC but could also be enumerated within the kernel via something like a PCI or USB bus.

The Linux kernel itself enumerates GPIO character devices at two paths:

  1. /dev/gpiochipN
  2. /sys/bus/gpiochipN

It is best not to assume that a device will always be enumerated in the same order (especially if it is connected via a bus). In order to reliably find the correct chip, there are a few approaches that one could reasonably take:

  1. Create a udev rule that will match attributes of the device and setup a symlink to the device.
  2. Iterate over all available chips using the chips() call to find the device with matching criteria.
  3. For simple cases, just using the enumerated path is fine (demo work). This is discouraged for production.

Methods

impl Chip
[src]

Open the GPIO Chip at the provided path (e.g. /dev/gpiochip<N>)

Get the fs path of this character device (e.g. /dev/gpiochipN)

The name of the device driving this GPIO chip in the kernel

A functional name for this GPIO chip, such as a product number. Might be an empty string.

As an example, the SoC GPIO chip on a Raspberry Pi is "pinctrl-bcm2835"

The number of lines/pins indexable through this chip

Not all of these may be usable depending on how the hardware is configured/muxed.

Get a handle to the GPIO line at a given offset

The actual physical line corresponding to a given offset is completely dependent on how the driver/hardware for the chip works as well as the associated board layout.

For a device like the NXP i.mx6 SoC GPIO controller there are several banks of GPIOs with each bank containing 32 GPIOs. For this hardware and driver something like GPIO2_5 would map to offset 37.

Important traits for LineIterator

Get an interator over all lines that can be potentially access for this chip.

Trait Implementations

impl Debug for Chip
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Chip

impl Sync for Chip