From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jacek Anaszewski Subject: Re: Single gpio shared by LED and switch? Date: Tue, 08 Sep 2015 12:51:40 +0200 Message-ID: <55EEBDBC.8040408@samsung.com> References: <55ED8B36.60108@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailout1.w1.samsung.com ([210.118.77.11]:55164 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754120AbbIHKvo (ORCPT ); Tue, 8 Sep 2015 06:51:44 -0400 In-reply-to: Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: Geert Uytterhoeven Cc: Linus Walleij , "linux-gpio@vger.kernel.org" , "linux-leds@vger.kernel.org" Hi Geert, Thanks for sharing this. On 09/07/2015 03:22 PM, Geert Uytterhoeven wrote: > Hi Jacek, > > On Mon, Sep 7, 2015 at 3:03 PM, Jacek Anaszewski > wrote: >> On 09/01/2015 07:00 PM, Geert Uytterhoeven wrote: >>> I'm wondering if there already exists a driver for a gpio that's connected >>> to both an LED and an input switch. >>> >>> I'd expect such a hardware configuration to be fairly common, as gpios can >>> be >>> a limited resource. >>> Most of the time the gpio would be in output mode, driving the LED, but at >>> regular intervals the mode would be changed for a very short moment to >>> input, >>> to monitor the state of the switch. >>> >>> I had a quick look at various drivers (and of course at >>> Documentation/gpio/drivers-on-gpio.txt), but couldn't find any. >>> >>> Does such a hybrid of "leds-gpio" and "gpio-keys(-polled)" already exists? >> >> Can you share an example of such a circuit? Would it be possible to > > Something like this? > > VCC VCC > | | > R R > | | > __|__ | | > +---o o---+ _|_ > | | \ / > | | --- > GND R | > | | > | |-+ > | |<+ > GPIO -----------------+---------|-| > | > | > GND You would need also resistor to avoid short-circuit when the switch is on. > >> construct it without additional GPIO driven transistor? > > Perhaps just like this? > > VCC > | > R > | > | > _|_ > \ / > --- > | > | > GPIO -----R-----------+ > | > | > | o > -| > | o > | > | > GND > We'd have to ask Linus if he welcomes drivers for this type of home-made circuits in mainline. If yes, then probably someone would have to build the circuit, develop and test the driver on it, and finally come up with a detailed documentation. Are you the volunteer? :) -- Best Regards, Jacek Anaszewski