linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yongjun <weiyongjun@huaweicloud.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: Wei Yongjun <weiyongjun1@huawei.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/3] gpio: sim: document use case for interrupt controller
Date: Mon, 26 Sep 2022 08:44:28 +0000	[thread overview]
Message-ID: <20220926084428.1792815-4-weiyongjun@huaweicloud.com> (raw)
In-Reply-To: <20220926084428.1792815-1-weiyongjun@huaweicloud.com>

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


      parent reply	other threads:[~2022-09-26  8:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26  8:44 [PATCH v2 0/3] allow gpio simulator be used as interrupt controller Wei Yongjun
2022-09-26  8:44 ` [PATCH v2 1/3] genirq/irq_sim: Allow both one and two cell bindings Wei Yongjun
2022-09-26 11:24   ` Bartosz Golaszewski
2022-09-26 12:55     ` Marc Zyngier
2022-09-28  7:32       ` Wei Yongjun
2022-09-28  7:47         ` Marc Zyngier
2022-09-26  8:44 ` [PATCH v2 2/3] gpio: sim: make gpio simulator can be used as interrupt controller Wei Yongjun
2022-09-26  8:44 ` Wei Yongjun [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220926084428.1792815-4-weiyongjun@huaweicloud.com \
    --to=weiyongjun@huaweicloud.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=weiyongjun1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).