From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jacek Anaszewski Subject: Re: Single gpio shared by LED and switch? Date: Wed, 09 Sep 2015 09:25:27 +0200 Message-ID: <55EFDEE7.20201@samsung.com> References: <55ED8B36.60108@samsung.com> <55EEBDBC.8040408@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]:31395 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751214AbbIIHZb (ORCPT ); Wed, 9 Sep 2015 03:25:31 -0400 In-reply-to: Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: Linus Walleij Cc: Geert Uytterhoeven , "linux-gpio@vger.kernel.org" , "linux-leds@vger.kernel.org" On 09/08/2015 04:37 PM, Linus Walleij wrote: > On Tue, Sep 8, 2015 at 12:51 PM, Jacek Anaszewski > wrote: >> On 09/07/2015 03:22 PM, Geert Uytterhoeven wrote: > >>> 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. > > There is a resistor AFAICT. Indeed. For some reason my mind filtered out these 'R' characters. > But consider the GPIO side which is opaque > here. When used as input it is often high impedance > but when used to drive it is not. > > Doesn't this mean the output actually has to be > open collector (open drain)? I think that GPIO control register would have to be altered to switch between particular modes. Let's analyze possible modes, assuming that the transistor is a bipolar PNP: LED_OFF: GPIO in output mode, state 1. LED_ON: GPIO in pull down mode (or output 0?) The drawback here is that additional current flow will occur from VCC to GPIO, read SW state: GPIO in input mode, high impedance (the LED would be off for this period) Correct me if I'm wrong, I haven't played with electronics for a long time. > In that case we should enforce that in the software > framework too so we protect people from shooting > themselves in the foot. We would have to use pinctrl for this, I presume. >> 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? :) > > Of course he's considering it or he wouldn't write :) > > I'm curious about what comes out of this, this is exactly > the type of problems that the GPIO subsystem is about > to help with. That's great. It seems that the potential driver would best fit for GPIO subsystem, and we could think about creating some wrapper in the LED subsystem, to make it compatible with led-triggers. -- Best Regards, Jacek Anaszewski