Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp990830pxf; Thu, 11 Mar 2021 22:08:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTlAmKW3fLCOlUpEZ9rKSXdUUPB166mogvDQ0J6imLH4+6bjXacUdYGx1Ppa+Nd1cEdDF3 X-Received: by 2002:a05:6402:510f:: with SMTP id m15mr12560831edd.328.1615529286290; Thu, 11 Mar 2021 22:08:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615529286; cv=none; d=google.com; s=arc-20160816; b=i2+t+JxvkXEq7MSiN9uGNlcDfT+pLR9+u9YujRzrJ/1LzYnaavtjsQ0U1v78HsbsO5 VOF7QHy72Osd/zsXLDVQKNA69Kabc0we5UwburG7dwKZp8Qm0+n+dm5OEUmdONKBfIEm dqle4YFEANQfcIMLOEn5S2uPvoJuTD80svk/z9F3M45EDZBepCp4UMBRIxmPQX7bw1Dv hWKF3hLnv38E/3o+QW2bD59tj5HY7ACULFcDTfuGd5hFq4Yvpk5kbPh8/eqkRNl9WUq9 6h0xUF0G8fT0Q6FJcSK42UylwsDDDprt82MlZNP/UR7Nec413CsVZgPNOE4cF7zAwxAF Ir9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=1lBJ2NyNaf1O+DoZbElpQUd/ldKr/tuisvr410XeyXk=; b=Mg1MtmtIr9p28RHmhnEVWORZDXSyuf0yK9BGMqrrMiZM5jz9OLT24NVJY5PpyNzAdP DhVdgeLD7oeE5IRyxUDVoVsnS9sMsMrESRfsUwOf2nEI5swrj/e6lOoEMn8ll4QNpajp F9JF0dnor+Nj+giqBHwk1Ey5gIH0Q3FTkzInsAXnxpFyLfxcCOkHKgpncT84x56cIbDL qrE4fNKyeg+oENYYO5MzrlIK1RQV2n3gclGrrlTAWiCoHggVmFOfFSB5N24aaLTp7j4k IBEctxiw0ZP7i+ZZ0s8Kn13kghrekXVp8k10JaaE5R5uwW5GNbIGB9C3PcJUvZN5kGlD Fb3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nic.cz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx21si3251549ejc.503.2021.03.11.22.07.43; Thu, 11 Mar 2021 22:08:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nic.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbhCLF7f (ORCPT + 99 others); Fri, 12 Mar 2021 00:59:35 -0500 Received: from lists.nic.cz ([217.31.204.67]:59370 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbhCLF70 (ORCPT ); Fri, 12 Mar 2021 00:59:26 -0500 Received: from localhost (unknown [IPv6:2a0e:b107:ae1:0:3e97:eff:fe61:c680]) by mail.nic.cz (Postfix) with ESMTPSA id 4FBC21409D7; Fri, 12 Mar 2021 06:59:24 +0100 (CET) Date: Fri, 12 Mar 2021 06:59:22 +0100 From: Marek Behun To: Hermes Zhang Cc: Pavel Machek , Dan Murphy , kernel , "linux-kernel@vger.kernel.org" , "linux-leds@vger.kernel.org" Subject: Re: [PATCH] leds: leds-dual-gpio: Add dual GPIO LEDs driver Message-ID: <20210312065922.53468d07@nic.cz> In-Reply-To: <161920e0746e4c0daff7f83163b71677@XBOX03.axis.com> References: <20210311130408.10820-1-chenhui.zhang@axis.com> <20210311163814.74c1885f@nic.cz> <20210311163951.0046fb5c@nic.cz> <161920e0746e4c0daff7f83163b71677@XBOX03.axis.com> 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=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-100.0 required=5.9 tests=SHORTCIRCUIT, USER_IN_WELCOMELIST,USER_IN_WHITELIST shortcircuit=ham autolearn=disabled version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.nic.cz X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 Mar 2021 04:48:52 +0000 Hermes Zhang wrote: > > > > Sorry, leds-regulator has only a binary state LED. > > > > Maybe you could extend leds-regulator to be able to use all regulator states? > > > > Or you can extend leds-gpio driver to support N states via log N gpios, > > instead of adding new driver. > > It seems a good idea to extend leds-gpio, so in my case, I should have such dts: > > 63 leds { > 64 compatible = "gpio-leds"; > 65 > 66 recording_front { > 67 label = "recording_front:red"; > 68 gpios = <&gpio 130 GPIO_ACTIVE_HIGH>, <&gpio 129 GPIO_ACTIVE_HIGH>; > 69 default-state = "off"; > 70 }; > 71 }; > > For my case, two leds is enough, but it sill easy to extend the support number bigger than two. And the length of gpios array is not fixed, so it could compatible with exist "gpio-leds" dts, right? > > If this idea work, should I create a new commit or still in this track (V2)? However you want :) Look at the states property of gpio regulator: https://www.kernel.org/doc/Documentation/devicetree/bindings/regulator/gpio-regulator.yaml It is possible to have a multi-GPIO LED which brightness is set via N GPIOs and it has 2^N brightness states encoded by binary values of those GPIOs, but it is entirely possible to have less than 2^N states, or that the states are encoded in a different way. In the first version though imlpemenent just the simplest case: N GPIOs with 2^N states. Marek