We have multiple GPIO controllers where each pin effectively only serves one purpose. For example, if the device-tree entry is the following:
i2c_expander: pca9506@20 {
compatible = "nxp,pca9505";
reg = <0x20>;
gpio-controller;
#gpio-cells = <2>;
};
Most of these GPIOs are basically just a binary switch. To toggle one of these ‘binary switches’, we do the following steps:
- Export the GPIO device
- Set the direction to output
- Write values
This seems to be a bit tedious, given that steps 1 and 2 should always happen.
Is the only way to achieve steps 1 and 2 automatically to write a custom kernel driver? It seems to me that there should be some generic driver that does the job for you. Ideally, this “generic driver” exports (for example) GPIO pin 4 under some name with direction out. Is this possible or does one always have to write a custom driver for that?