All of lore.kernel.org
 help / color / mirror / Atom feed
* passing two interrupts two an I2C driver
@ 2013-08-16 14:47 Jacek Anaszewski
  2013-08-16 18:48 ` Stephen Warren
  0 siblings, 1 reply; 26+ messages in thread
From: Jacek Anaszewski @ 2013-08-16 14:47 UTC (permalink / raw)
  To: devicetree
  Cc: linux-iio, Jonathan Cameron, maxime.ripard, lars, l.czerwinski,
	rob.herring, pawel.moll, mark.rutland, swarren, ian.campbell,
	s.nawrocki

Hi all,

I'd like to consult the implementation of DT binding for the I2C device
that exposes two interrupt pins (INT1 and INT2). Both pins can be
configured to generate either data ready interrupts or event interrupts.
I want to implement DT binding that will handle also the situation
when only one of the interrupt sources is routed from the device
to the CPU.

Below is my implementation using interrupt-map:

+++ b/Documentation/devicetree/bindings/iio/pressure/lps331ap.txt
@@ -0,0 +1,41 @@
+* STMicroelectronics LPS331AP barometer sensor
+
+Required properties:
+
+  - compatible : should be "st,lps331ap"
+  - reg : the I2C address of the barometer
+
+Optional properties:
+
+  - st,data-ready-interrupt-pin : redirect DRDY on pin INT1 (1) or pin 
INT2 (2) (u8)
+  - interrupt-parent : phandle to the interrupt map subnode
+  - interrupts : interrupt mapping for LPS331AP interrupt sources:
+                2 sources: 0 - data ready, 1 - threshold event
+  - irq-map : irq sub-node defining interrupt map
+             (all properties listed below are required):
+      - #interrupt-cells : should be 1
+      - #address-cells : should be 0
+      - #size-cells : should be 0
+      - interrupt-map : table of entries consisting of three child 
elements:
+         - unit_interrupt_specifier - 0 : data ready, 1 : threshold event
+         - interrupt parent phandle
+         - parent unit interrupt specifier consisiting of two elements:
+             - index of the interrupt within the controller
+             - flags : should be 0
+
+Example:
+
+lps331ap@5d {
+       compatible = "st,lps331ap";
+       reg = <0x5d>;
+       drdy-int-pin = /bits/ 8 <2>;
+       interrupt-parent = <&irq_map>;
+       interrupts = <0>, <1>;
+
+       irq_map: irq-map {
+               #interrupt-cells = <1>;
+               #address-cells = <0>;
+               #size-cells = <0>;
+               interrupt-map = <0 &gpf0 5 0>;
+       };
+};

And here is how the driver uses this information:

  - if interrupt-map is empty then the driver configures
    itself to work without interrupt support
  - if only one interrupt source is available then the driver
    configures the device to generate data ready interrupts on
    the corresponding INTx pin (in this case the driver must know which
    of the device pins is routed to the cpu -
    st,data-ready-interrupt-pin property conveys this information)
  - if both interrupt sources are available then the driver configures
    the device to generate data ready interrupts on the interrupt pin
    corresponding to the interrupt source with index 0 and event
    interrupts to the interrupt source with index 1.

This solution seems to be a little awkward so I'd like to ask
if there is any neater way to handle presented requirements.
The solution must facilitate passing information about two
interrupt sources two the I2C driver. I have been unable to find
similar solution in the kernel so far.

Thanks,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-08-22 20:26 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-16 14:47 passing two interrupts two an I2C driver Jacek Anaszewski
2013-08-16 18:48 ` Stephen Warren
2013-08-19  8:42   ` Mark Rutland
2013-08-19 16:09     ` Stephen Warren
2013-08-20  8:44       ` Mark Rutland
2013-08-20 16:25         ` Stephen Warren
2013-08-21  8:54           ` Mark Rutland
2013-08-22 12:45             ` Rob Herring
2013-08-22 20:26               ` Stephen Warren
2013-08-21 11:53     ` Jacek Anaszewski
2013-08-21 12:34       ` Pawel Moll
     [not found]       ` <5214AA52.2060209-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-08-21 12:37         ` Pawel Moll
2013-08-21 12:37           ` Pawel Moll
2013-08-21 12:37           ` Pawel Moll
2013-08-21 17:54           ` Mark Brown
2013-08-21 17:54             ` Mark Brown
     [not found]             ` <20130821175446.GI26118-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-08-22  9:23               ` Pawel Moll
2013-08-22  9:23                 ` Pawel Moll
2013-08-22  9:23                 ` Pawel Moll
2013-08-22 11:26                 ` Mark Brown
2013-08-22 11:26                   ` Mark Brown
     [not found]                   ` <20130822112619.GD26118-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-08-22 11:44                     ` Pawel Moll
2013-08-22 11:44                       ` Pawel Moll
2013-08-22 11:44                       ` Pawel Moll
2013-08-22 13:19                       ` Mark Brown
2013-08-22 13:19                         ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.