lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150127105931.GN1451@lahna.fi.intel.com>
Date:	Tue, 27 Jan 2015 12:59:31 +0200
From:	Mika Westerberg <mika.westerberg@...ux.intel.com>
To:	Mark Rutland <mark.rutland@....com>
Cc:	Jiri Kosina <jkosina@...e.cz>,
	Benjamin Tissoires <benjamin.tissoires@...hat.com>,
	Rob Herring <robh+dt@...nel.org>,
	Pawel Moll <Pawel.Moll@....com>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Kumar Gala <galak@...eaurora.org>,
	Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
	"linux-input@...r.kernel.org" <linux-input@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] HID: i2c-hid: Add support for GPIO interrupts

On Tue, Jan 27, 2015 at 10:39:25AM +0000, Mark Rutland wrote:
> > If the above is not the right way to use GPIOs as interrupt, can you
> > please tell me how it is done then?
> 
> 
> So lets say we have a device which generates an interrupt:
> 
> 	device@f00 {
> 		compatible = "some-interrupting-device";
> 		reg = <0xf00 0x100>;
> 		interrupts = < ... >;
> 	};
> 
> It's intended that this is connected to an interrupt controller:
> 
> 	ic: interrupt-controller@b00 {
> 		compatible = "some-interrupt-controller";
> 		reg = <0xb00 0x100>;
> 		#interrupt-cells = <1>;
> 	};
> 
> 	device@f00 {
> 		compatible = "some-interrupting-device";
> 		reg = <0xf00 0x100>;
> 		interrupt-parent = <&ic>;
> 		interrupts = <0x3>;
> 	};
> 
> But in some cases, this gets connected to a GPIO controller. In these
> cases, the device is still logically generating an interrupt, and the
> fact that the endpoint is an interrupt controller is irrelevant from the
> PoV of the device. So we acknowledge that the GPIO controller is also
> capable of acting as an interrupt controller, and mark it as such:
> 
> 	gc: gpio-controller@000 {
> 		compatible = "some-gpio-controller";
> 		reg = <0x000 0x100>;
> 		#gpio-cells = <1>;
> 		#interrupt-cells = <1>;
> 	};
> 
> 	device@f00 {
> 		compatible = "some-interrupting-device";
> 		reg = <0xf00 0x100>;
> 		interrupt-parent = <&gc>;
> 		interrupts = <0x1>;
> 	};
> 
> Thus the device binding only describes the logical interrupt, and the
> driver only needs to handle interrupts.

OK.

> In cases where the binding/driver actually care about the GPIO being a
> GPIO (e.g. for card detect in an MMC controller), describing the GPIO as
> a GPIO makes sense, and we can try gpio_to_irq as an optimisation over
> polling the state of the GPIO.

Well, I've seen touch panels where you actually need to switch the GPIO
to be output and do some magic before you can use the same GPIO as an
interrupt.

> > BTW, passing NULL to gpiod_get() implies property named "gpios" in DT
> > (which is why I added it to the documentation).
> 
> Sure. My concern is that we should not need to deal with GPIOs in this
> case were the GPIO is only there to function as an interrupt.
> 
> Given that GpioInt seems to describe an interrupt which happens to be
> backed by a GPIO, I don't understand what it is necessary to translate
> this as a GPIO rather than an interrupt. If it were going to be used as
> a GPIO, then it would be a GpioIO object, no?

OK, so where do you propose we handle the translation if not in the
driver? Also keep in mind that some of the devices may have multiple
GpioInt()s.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ