0

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

sawdust
  • 16,103
  • 3
  • 40
  • 50
Dukel
  • 11
  • 4
  • There is not a single driver that fetches something from the Device Tree. This driver fetches `clock-frequency` in case there is no clock defined, the GPIO library (https://elixir.bootlin.com/linux/v5.4.148/source/drivers/gpio/gpiolib-of.c#L629) handles GPIO hogs and so on... – 0andriy Nov 26 '22 at 10:45
  • `ngpios` is not needed since it's hard coded in the driver (https://elixir.bootlin.com/linux/v5.4.148/source/drivers/tty/serial/sc16is7xx.c#L439). – 0andriy Nov 26 '22 at 10:49
  • I don't know what is that `gpio2number` tool, have you tried with the official `gpiodetect`, `gpioinfo`, etc? – 0andriy Nov 26 '22 at 11:36
  • This is a bit counter intuitive. You say there is no driver that fetches anything from the device tree and right after you say it does fetch the clock frequency . It also gets the info for what IRQ pin to use. Ah right I can remove ngpios (Y). gpiodectect is not enabled but I recon it does the same as gpio2number shown in the added images. – Dukel Nov 28 '22 at 09:59
  • Are there any clues in the kernel log? – Ian Abbott Nov 29 '22 at 14:04
  • Yeah, it's quality of my English from time to time... What I meant is that the properties are being read by several drivers and not a single one. – 0andriy Dec 04 '22 at 18:11

1 Answers1

1

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.

Dukel
  • 11
  • 4
  • Looks like something was wrong with the GPIO hogs in that version of the Linux kernel, or something is not correct in your approach (I tend to believe in the latter than in the former). – 0andriy Dec 04 '22 at 18:13