From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACC6BC433E0 for ; Fri, 12 Mar 2021 09:04:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C8BA64FD0 for ; Fri, 12 Mar 2021 09:04:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232509AbhCLJDz convert rfc822-to-8bit (ORCPT ); Fri, 12 Mar 2021 04:03:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232417AbhCLJDa (ORCPT ); Fri, 12 Mar 2021 04:03:30 -0500 X-Greylist: delayed 62617 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 12 Mar 2021 01:03:30 PST Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 889A6C061574; Fri, 12 Mar 2021 01:03:30 -0800 (PST) Received: from localhost (unknown [IPv6:2a0e:b107:ae1:0:3e97:eff:fe61:c680]) by mail.nic.cz (Postfix) with ESMTPSA id 493681408F2; Fri, 12 Mar 2021 10:03:28 +0100 (CET) Date: Fri, 12 Mar 2021 10:03:27 +0100 From: Marek Behun To: Hermes Zhang Cc: Alexander Dahl , "linux-leds@vger.kernel.org" , Pavel Machek , Dan Murphy , kernel , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] leds: leds-dual-gpio: Add dual GPIO LEDs driver Message-ID: <20210312100327.3c3c47ba@nic.cz> In-Reply-To: References: <20210311130408.10820-1-chenhui.zhang@axis.com> <2315048.uTtSMl1LR1@ada> X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org On Fri, 12 Mar 2021 08:48:55 +0000 Hermes Zhang wrote: > Hi Alexander, > > > Am Donnerstag, 11. März 2021, 14:04:08 CET schrieb Hermes Zhang: > > > From: Hermes Zhang > > > > > > Introduce a new Dual GPIO LED driver. These two GPIOs LED will act as > > > one LED as normal GPIO LED but give the possibility to change the > > > intensity in four levels: OFF, LOW, MIDDLE and HIGH. > > > > Interesting use case. Is there any real world hardware wired like that you > > could point to? > > > > Yes, we have the HW, it's not a chip but just some circuit to made of. > > > > +config LEDS_DUAL_GPIO > > > + tristate "LED Support for Dual GPIO connected LEDs" > > > + depends on LEDS_CLASS > > > + depends on GPIOLIB || COMPILE_TEST > > > + help > > > + This option enables support for the two LEDs connected to GPIO > > > + outputs. These two GPIO LEDs act as one LED in the sysfs and > > > + perform different intensity by enable either one of them or both. > > > > Well, although I never had time to implement that, I suspect that could > > conflict if someone will eventually write a driver for two pin dual color LEDs > > connected to GPIO pins. We actually do that on our hardware and I know > > others do, too. > > > > I asked about that back in 2019, see this thread: > > > > https://www.spinics.net/lists/linux-leds/msg11665.html > > > > At the time the multicolor framework was not yet merged, so today I would > > probably make something which either uses the multicolor framework or at > > least has a similar interface to userspace. However, it probably won't surprise > > you all, this is not highest priority on my ToDo list. ;-) > > > > (What we actually do is pretend those are separate LEDs and ignore the > > conflicting case where both GPIOs are on and the LED is dark then.) > > > > Yes, that case seems conflict with mine, the pattern for me is like: > > P1 | P2 | LED > -- + -- + ----- > 0 | 0 | off > 0 | 1 | Any color > 1 | 0 | Any color > 1 | 1 | both on > > Now I'm investigate another way from Marek's suggestion by using REGULATOR_GPIO, to see if could meet my requirement. If yes, then I do think no new driver is needed. Maybe you could even implement multicolor-gpio, now that we have multicolor LED class :) Marek