Search code examples
linux-device-drivergpiodevice-tree

GPIO controller settings in DTS


I'm trying to set GPIO0 of the SC16IS750 to an output and default high. However, there is something wrong with my GPIO hogging. If I don't include the child node p0 I'm able to find the gpiochip (/dev/gpiochip2) and the names per GPIO. I used the bindings and a previous question as info.

I'm using the Linux kernel driver for the SC16IS750 (Linux kernel v5.4.148).

I would also be very interested which part of the drive fetches the DTS information. I think this is the function sc16is7xx_i2c_probe(), but I find it hard to follow the structure of the driver.

/* I2C-to-UART converter */
sc16is750: sc16is750@48 {
   compatible = "nxp,sc16is750";
   reg = <0x48>;
   clock-frequency = <14746500>;
   interrupt-parent = <&gpio>;
   interrupts = <28 0>;
   gpio-controller;
   #gpio-cells = <2>;

   /* ngpios = <8>; */
   /* gpio-line-names = "Fan", "1", "TACO", "3", "4", "5", "6", "7"; */
   p0 {
      gpio-hog;
      gpios = <0x0 0x0>;
      output-high;
      line-name = "Fan";
   };
};

Without child node, ngpios and gpio-line uncommented

With child node p0, ngpios and gpio-line commented


Solution

  • It does not seem to be possible to use gpio hogging with this driver.

    Instead I edit the drive a bit at the initialization of the port data

    /* Set GPIO as Output-high*/
    sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IODIR_REG,
                    0x0f);
    sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IOSTATE_REG,
                    0x0f);
    

    A few seconds delay from boot before this will take effect but that would be no different from the dts change.