cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
derjan
Visitor
Visitor
867 Views
Registered: ‎04-17-2018

AXI GPIO names in dual configuration

I am having an AXI GPIO controller in my design that is used in dual-controller mode. The device-tree entry looks like this (Please ignore that each controller currently only handles 8 GPIOs, there will be more in the future so it can't be handled in single-controller mode)

 

 

    axi_gpio_0: gpio@a0000000 {
      #gpio-cells = <0x2>;
      #interrupt-cells = <0x2>;
      compatible = "xlnx,xps-gpio-1.00.a";
      gpio-controller;
      interrupt-controller;
      interrupt-parent = <0x4>;
      interrupts = <0x0 0x68 0x4>;
      reg = <0x0 0xa0000000 0x0 0x1000>;
      xlnx,all-inputs = <0x0>;
      xlnx,all-inputs-2 = <0x1>;
      xlnx,all-outputs = <0x1>;
      xlnx,all-outputs-2 = <0x0>;
      xlnx,dout-default = <0x35>;
      xlnx,dout-default-2 = <0x0>;
      xlnx,gpio-width = <0x8>;
      xlnx,gpio2-width = <0x8>;
      xlnx,interrupt-present = <0x1>;
      xlnx,is-dual = <0x1>;
      xlnx,tri-default = <0xffffffff>;
      xlnx,tri-default-2 = <0xffffffff>;
    };

I was now trying to add names to the GPIO to easier use the new character-device GPIO interface:

 

 

 

&axi_gpio_0 {
  gpio-line-names =
    "LED0",
    "LED1",
    "LED2",
    "LED3",
    "LED4",
    "LED5",
    "LED6",
    "LED7",
    "DIP0",
    "DIP1",
    "DIP2",
    "DIP3",
    "DIP4",
    "DIP5",
    "DIP6",
    "DIP7";
};

However, what happens is, the eight GPIOs of both controllers will be named LED0-7 and I am getting the following warning during startup:

 

 

[    0.191057] gpio gpiochip0: gpio-line-names specifies 16 line names but there are 8 lines on the chip                                                                │··································································································
[    0.191729] XGpio: /amba_pl@0/gpio@a0000000: registered, base is 504                                                                                                 │··································································································
[    0.192114] gpio gpiochip1: gpio-line-names specifies 16 line names but there are 8 lines on the chip                                                                │··································································································
[    0.192415] XGpio: /amba_pl@0/gpio@a0000000: dual channel registered, base is 496

Looking in the code (drivers/gpio/gpio-xilinx.c), apparently, when dual-mode is used, a second controller is created and the xilinx-specific parameters are parsed separately (essentially those with a "2" in the name). However, the following call is the same for both controllers since it is not Xilinx specific.

 

status = of_mm_gpiochip_add(np, &chip->mmchip);

Apparently this attempts to read the same gpio-line-names property for both controllers (each of which only has 8 lines) and just assigns the first eight names to the GPIO lines of both controllers. I can verify this using lsgpio:

 

GPIO chip: gpiochip1, "/amba_pl@0/gpio@a0000000", 8 GPIO lines                                                                                                          │··································································································
        line  0: "LED0" unused                                                                                                                                          │··································································································
        line  1: "LED1" unused                                                                                                                                          │··································································································
        line  2: "LED2" unused                                                                                                                                          │··································································································
        line  3: "LED3" unused                                                                                                                                          │··································································································
        line  4: "LED4" unused                                                                                                                                          │··································································································
        line  5: "LED5" unused                                                                                                                                          │··································································································
        line  6: "LED6" unused                                                                                                                                          │··································································································
        line  7: "LED7" unused                                                                                                                                          │··································································································
GPIO chip: gpiochip0, "/amba_pl@0/gpio@a0000000", 8 GPIO lines                                                                                                          │··································································································
        line  0: "LED0" unused                                                                                                                                          │··································································································
        line  1: "LED1" unused                                                                                                                                          │··································································································
        line  2: "LED2" unused                                                                                                                                          │··································································································
        line  3: "LED3" unused                                                                                                                                          │··································································································
        line  4: "LED4" unused                                                                                                                                          │··································································································
        line  5: "LED5" unused                                                                                                                                          │··································································································
        line  6: "LED6" unused                                                                                                                                          │··································································································
        line  7: "LED7" unused

Furthermore, it seems a bit more difficult to discern the two controllers by name at runtime. I assume (and tests seem to agree) that the one with the lower ID will be the first controller. But it seems that there is no way to be sure.

 

Is this going to be fixed at some point so that line-naming is properly supported by the driver? Is it currently better to just add a second GPIO controller instead of using dual-mode?

0 Kudos
1 Reply
jkarch1948
Observer
Observer
346 Views
Registered: ‎01-17-2020

Did you ever find a resolution to this question?  I'm thinking of modifying the gpio-xilinx driver to add this functionality.

-Josh

0 Kudos