Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: vz@mleia.com (Vladimir Zapolskiy)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/2] gpio: lpc18xx: add GPIO pin interrupt controller support
Date: Thu, 29 Nov 2018 00:48:39 +0200	[thread overview]
Message-ID: <20181128224841.3646-1-vz@mleia.com> (raw)

>From LPC18xx and LPC43xx User Manuals the GPIO controller consists of
the following blocks:
* GPIO pin interrupt block at 0x40087000, this change adds its support,
* GPIO GROUP0 interrupt block at 0x40088000,
* GPIO GROUP1 interrupt block at 0x40089000,
* GPIO port block at 0x400F4000, it is supported by the original driver.

While the blocks are relatively independant and potentially they can
be defined under their own device tree nodes, all blocks share the
same clock to enable access to register interfaces and the same reset
signal.

The change extends the existing gpio at 400f4000 device tree node described
in arch/arm/boot/dts/lpc18xx.dtsi by adding 'reg-names' property to

	gpio: gpio at 400f4000 {
		compatible = "nxp,lpc1850-gpio";
		reg = <0x400f4000 0x4000>, <0x40087000 0x1000>,
		      <0x40088000 0x1000>, <0x40089000 0x1000>;
		reg-names = "gpio", "gpio-pin-ic",
			    "gpio-group0-ic", "gpio-gpoup1-ic";
		clocks = <&ccu1 CLK_CPU_GPIO>;
		resets = <&rgu 28>;
		gpio-controller;
		#gpio-cells = <2>;
		interrupt-controller;
		#interrupt-cells = <2>;
	};

Note that all 4 blocks find their place, but the functional change adds
support of the GPIO pin interrupt contoller only.

Alternative and probably better representation of the GPIO pin interrupt
contoller block can be like this one added in parallel to gpio at 400f4000 {}:

	gpio_pin: interrupt-controller at 40087000 {
		compatible = "nxp,lpc1850-gpio-pin-ic";
		reg = <0x40087000 0x1000>;
		clocks = <&ccu1 CLK_CPU_GPIO>;
		resets = <&rgu 28>;
		interrupt-controller;
		#interrupt-cells = <2>;
	};

The unpleasant side effects associated with this representation are:

1) both gpio at 400f4000 and interrupt-controller at 40087000 (plus potential
   interrupt-controller at 40088000 and interrupt-controller at 40089000) share
   the same reset and the same clock,
2) separate device node and 'compatible' imply a new drivers/irqchip/
   driver, it is totally okay, but
3) while Linux device drivers provide interfaces and support well usage
   of the same reset or clock, interrupt controller drivers does not
   depend on clock providers, of_clk_get() will ask for defer, but
   IRQCHIP_DECLARE()d initialization won't be reprobed,
4) it might be more or less reliably assumed that GPIO pin interrupt
   controller does not get any consumer in runtime, who is not the
   consumer of the same GPIO which serves as an interrupt, so implicitly
   access to the interrupt controller functions will happen after
   the registration of the GPIO controller driver, which in turn enables
   the shared clock, and thus access to the interrupt controller registers
   will be successful then, but you see, the complexity and indirection
   leads to unavoidable fragility.

So, I go ahead with the extension of the exisitng GPIO controller device
node, comments and other opinions are welcome as usual.

The change depends on a minor clean-up series, which was sent aforehand:
* https://marc.info/?l=linux-gpio&m=154344413726424&w=1

The actual lpc18xx.dtsi change will be sent afterwards after getting
the acceptance of the proposed device tree node changes.

Marc, this is the change, which I had a luck to discuss with you on ELCE.

Vladimir Zapolskiy (2):
  dt-bindings: gpio: lpc18xx: describe interrupt controllers of GPIO controller
  gpio: lpc18xx: add GPIO pin interrupt controller support

 .../bindings/gpio/nxp,lpc1850-gpio.txt        |  38 ++-
 drivers/gpio/Kconfig                          |   1 +
 drivers/gpio/gpio-lpc18xx.c                   | 267 +++++++++++++++++-
 3 files changed, 293 insertions(+), 13 deletions(-)

-- 
2.17.1

             reply	other threads:[~2018-11-28 22:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 22:48 Vladimir Zapolskiy [this message]
2018-11-28 22:48 ` [PATCH 1/2] dt-bindings: gpio: lpc18xx: describe interrupt controllers of GPIO controller Vladimir Zapolskiy
2018-12-07  9:56   ` Linus Walleij
2018-11-28 22:48 ` [PATCH 2/2] gpio: lpc18xx: add GPIO pin interrupt controller support Vladimir Zapolskiy
2018-12-07 10:00   ` Linus Walleij

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=20181128224841.3646-1-vz@mleia.com \
    --to=vz@mleia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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