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

From: Wei Yongjun
Date: Mon Sep 26 2022 - 04:27:46 EST


From: Wei Yongjun <weiyongjun1@xxxxxxxxxx>

Add document for using GPIO sim as interrupt controller.

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

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
--
2.34.1