title: How to programmatically use GPIO Expander driver in Linux?
body: <p>I am trying to configure my Yocto Linux distro to setup two on-board I2C GPIO Expanders and document how to access them programmatically (i.e. from a C user application). The GPIO Expanders are both NXP PCA9557, which is supported by the <a href="https://github.com/torvalds/linux/blob/master/drivers/gpio/gpio-pca953x.c" rel="nofollow noreferrer">gpio-pca953x.c</a> kernel driver.</p>
  <p>I understand how to compile this driver into the kernel (using <code>CONFIG_GPIO_PCA953X</code> configuration option) and load it (using <code>modprobe</code>). I also understand I can instantiate these two I2C devices in the device tree (this is an embedded device, so the GPIO expanders are static and unchanging):</p>
  <pre class="lang-dts prettyprint-override"><code>gpio@20 {
      compatible = &quot;nxp,pca9557&quot;;
      reg = &lt;0x1a&gt;;
      gpio-controller;
      #gpio-cells = &lt;2&gt;;
  };
  </code></pre>
  <p>The information I'm lacking is how to use the gpio-pca953x driver with these instantiated devices? Do I need to associate these devices with that particular driver? What APIs do I use to access them in a user application written in C? Do these just act like normal GPIOs once I've configured them correctly?</p>
  <p>I'm more than happy to read through any relevant documentation, lengthy or otherwise, on how to do this. I'm just a beginner in Linux device drivers and have no idea where to go from here, despite a great deal of googling.</p>