diff mbox series

[v2,3/3] gpio: sim: document use case for interrupt controller

Message ID 20220926084428.1792815-4-weiyongjun@huaweicloud.com
State New
Headers show
Series allow gpio simulator be used as interrupt controller | expand

Commit Message

Wei Yongjun Sept. 26, 2022, 8:44 a.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

Add document for using GPIO sim as interrupt controller.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 Documentation/admin-guide/gpio/gpio-sim.rst | 44 +++++++++++++++++++++
 1 file changed, 44 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/admin-guide/gpio/gpio-sim.rst b/Documentation/admin-guide/gpio/gpio-sim.rst
index d8a90c81b9ee..7ccb3f80c90e 100644
--- a/Documentation/admin-guide/gpio/gpio-sim.rst
+++ b/Documentation/admin-guide/gpio/gpio-sim.rst
@@ -132,3 +132,47 @@  group there are two attibutes:
     ``value`` - allows to read the current value of the line which may be
                 different from the pull if the line is being driven from
                 user-space
+
+An example device-tree code defining a GPIO simulator as interrupt controller:
+
+.. code-block :: none
+
+    gpio-sim {
+        compatible = "gpio-simulator";
+
+        bank0 {
+            gpio-controller;
+            #gpio-cells = <2>;
+            ngpios = <16>;
+
+            interrupt-controller;
+            #interrupt-cells = <2>;
+
+            line0 {
+                gpio-hog;
+                gpios = <0 1>;
+                input;
+                line-name = "irq-sim";
+            }
+        };
+    };
+
+    spi: spi {
+        compatible = "spi-mockup";
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        can0: can@1 {
+            compatible = "microchip,mcp2515";
+            reg = <1>;
+            interrupt-parent = <&bank0>;
+            interrupts = <0 IRQ_TYPE_EDGE_BOTH>;
+        }
+    };
+
+Trigger irq by writing value to pull setting:
+
+.. code-block :: none
+
+    $ echo pull-down > /sys/devices/platform/gpio-sim/gpiochipX/sim_gpio0/pull
+    $ echo pull-up > /sys/devices/platform/gpio-sim/gpiochipX/sim_gpio0/pull