Tool/software:
Is there a kernel layer similar to libgpiod that operates GPIO by name?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Is there a kernel layer similar to libgpiod that operates GPIO by name?
Hi Stephen,
No, kernel doesn't use GPIO by name.
In kernel devicetree, gpio pins are specified according to gpio devicetree bindings, for example:
vdd_sd_dv: regulator-4 {
...
gpios = <&main_gpio0 31 GPIO_ACTIVE_HIGH>;
};
Then the kernel driver uses kernel gpiod framework API to initialize and use the GPIO pins.
Hi Bin,
Our project includes many character device drivers using the traditional method (with module_inti and module_exit). I tried to use devm_gpiod_get to access the gpio node defined in the device tree, but it failed to get the gpio.
Later, I finded that it might be necessary to convert the driver to the platform driver model in order to use the gpiod framework.
Is this actually the case? Can a driver implemented using the traditional method directly make use of the gpiod framework?
Hi Stephen,
No, you don't have to convert your driver to platform driver to use gpiod API. You can directly use gpiod_* functions implemented in gpio/gpiolib.c, such as gpiod_get(), gpiod_get_optional(), or gpiod_get_index_optional(), etc.
Search the kernel drivers/ directory for any example.