From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82D9A3921E7; Tue, 22 Sep 2026 14:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; cv=none; b=RM89cfws4CMAj0mxulyn0+CXLIAtM5uO2Ddct281+DDVTRQa5VC/ll8kHpr0EmHeOjqKQMx2vkqsvaQvR3svKZXBgcqxPjqVwZHb344YVg3osf9rYnxJ1kiLWNiECfNQ7+l05SMf/f80qq58zMGP6383Fp1k3XTLPIfIsov1AQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; c=relaxed/simple; bh=vJi86saIr1/40Et3dWwomOxIHMaM63R74DUM9jlg4H4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uilPegz2G4VFAF2nnIlvuGaujFepE0eF+T8Yof5vzFtIUGcM2lbQ1ZFE2K4vZHdr5bQQ8sCzyVs0IdkFEHLZJlucpAVtl032z5pfTGwuoomFupK4l2iF4DXc3W96x4f6VcGdKiXYjIJLC6YdHxsVg//P3I0iEwztpdH5nQ3iE1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=cCml8eyS; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="cCml8eyS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=vhXDYtyGCDRT+cNiO1bVxa+AteKhhtDcHPRBs2AsmQk=; b=cCml8eySAlApMpD0KTjYUcuYPr L73SVWMwl7FsDa3kovNDvjitRp6IyThIdc8cndkRMDcwk0mc1l4UoKtUIZNtgBt9n/P6G6tqvFaWd 1fCrjJ9ifml/NnVIlJVojfWEZTZq1IA7FARdiZLn8YjapwWF+4nUh3AftCSCg0D1FBnUTnRla/I6i S+d1wgdxj2G1iM5hMzfguCcP2bsbQKpyZBrvy+UbZRTchTUgj9Ewy/+6j7yl/cUq4/0XGEQWzl1UT z4URebESyfcPXt6PSH4fY3LXvAQ5m5iDHxgYmLI7wu0v0f74Adr7KuNMSuAfkaX93DK15662Une7n TOpaIeeA==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nF-000MgO-1L; Tue, 22 Sep 2026 16:48:25 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nE-000PP0-2n; Tue, 22 Sep 2026 16:48:24 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer , Krzysztof Kozlowski Subject: [PATCH v3 01/10] dt-bindings: leds: pca995x: Describe reset-gpios property Date: Tue, 22 Sep 2026 16:47:48 +0200 Message-ID: <3e6c859ffad2543243a9d55183e3bfbb9c5afe43.1790087890.git.nora.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) The PCA9952/PCA9955B/PCA9956B have a reset pin. Allow describing it in the Device Tree. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Nora Schiffer --- Documentation/devicetree/bindings/leds/nxp,pca995x.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/nxp,pca995x.yaml b/Docu= mentation/devicetree/bindings/leds/nxp,pca995x.yaml index ab8c90cbadb5c..201f32f1b8139 100644 --- a/Documentation/devicetree/bindings/leds/nxp,pca995x.yaml +++ b/Documentation/devicetree/bindings/leds/nxp,pca995x.yaml @@ -36,6 +36,9 @@ properties: "#size-cells": const: 0 =20 + reset-gpios: + maxItems: 1 + patternProperties: "^led@[0-9a-f]+$": type: object @@ -54,6 +57,7 @@ additionalProperties: false =20 examples: - | + #include #include =20 i2c { @@ -65,6 +69,7 @@ examples: reg =3D <0x01>; #address-cells =3D <1>; #size-cells =3D <0>; + reset-gpios =3D <&gpio2 5 GPIO_ACTIVE_LOW>; =20 led@0 { reg =3D <0x0>; --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CB38377A8C; Tue, 22 Sep 2026 14:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; cv=none; b=IygMJCM/voxayRJX2hBtQsKFLdJYQ7ndENHlYGVtHNVZ80ss+NPQoW40mPV5Mst7hr5MAqAB1CFkFvQl7TcNgap4Zpe9HR4iBPAPr2v9MUXFR5TsmYWribDEIdiB1vCarlEIe0H1T6PCMXs/8As/IgZCYUEr5+gPYJnIQgvvIsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; c=relaxed/simple; bh=dJQ/OjPO0d9VUJKeS9tCzL5uaO+w57R42kmzt6s02us=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VzP0f8IykBdt5oNiOfmVBJ8DZ6bs5M82+C7W5y3pr187+UIbEaeg9UGyUNkVmnkmPzaNR45kXEEXT84AGrABSPmiFqIbdTRx02GgAARz58f6htCZfTsv/nKnx2tyiOxv6ZHYNt9su4VjRHeOQHpWjR1qQ3YF4muA+R2VB5tvIWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=F5qaDQ4b; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="F5qaDQ4b" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=i7k5IvRMGds1MAPqGTDkTv6/b7coFgJ33EfhbQAkbc4=; b=F5qaDQ4b59mWLaE2LHg4Oi5Rxc Xvgm/2qQnf8ElUH0qLM3g2xOnoPsJB7/3+yVpVJ093TNMfHy3xGCfU+4d7oxEV9iI7Ty8DPJPWWnk 64Hd3xVR4r5A8genID4Kpj0914fBDisdTPNjw2KvkbuGa1gqPm5rtzNzwBio3T1QAUpK9kIsU+Goe U0UVTTrKJJJxyPdybvPEh31i85N/3uvZiWV/Is11O1RApmGN4MWim4quIm+o9WKLokI3n+YLlJbKU bpAvQl2rFj9vuFAHhheJtVu3SxJjkhBESD/UK3kH9J3xBtro1l2QNtBzTesQu9Lmdxby4C8YE70Ds TzmrFXOQ==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nF-000MgZ-3B; Tue, 22 Sep 2026 16:48:26 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nF-000PP0-0w; Tue, 22 Sep 2026 16:48:25 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer , Krzysztof Kozlowski Subject: [PATCH v3 02/10] dt-bindings: leds: pca995x: Describe nxp,output-gain property Date: Tue, 22 Sep 2026 16:47:49 +0200 Message-ID: <86db544bcf3413474bc3fac73e94bdc09af03867.1790087890.git.nora.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) Allow configuring the output current to adjust for different hardware designs. The output gain relates the output current with an external resistor connected to the LED driver. It does not directly correspond to a meaningful physical unit of measurement, so we refer to the datasheet for information on its calculation. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Nora Schiffer --- Documentation/devicetree/bindings/leds/nxp,pca995x.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/nxp,pca995x.yaml b/Docu= mentation/devicetree/bindings/leds/nxp,pca995x.yaml index 201f32f1b8139..372ecd18043e0 100644 --- a/Documentation/devicetree/bindings/leds/nxp,pca995x.yaml +++ b/Documentation/devicetree/bindings/leds/nxp,pca995x.yaml @@ -39,6 +39,14 @@ properties: reset-gpios: maxItems: 1 =20 + nxp,output-gain: + description: + Set the output gain controlling the LED current as described in the + PCA995x datasheets. + $ref: /schemas/types.yaml#/definitions/uint32 + default: 127 + maximum: 255 + patternProperties: "^led@[0-9a-f]+$": type: object --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2E54390609; Tue, 22 Sep 2026 14:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088515; cv=none; b=PRXPRnL3WBCdFuTxyCmuH0iMaRbWiD9o2HChWPzSSwyyFclkFTE1j1Z7d913x5vUwfR3jlsRmXVUOasvPKhKtHs1MbGp/mi/p2XLvZArT2zTZpM0ueQbm03f5mJzte9rfxtbakMRejinz19VuEv25kVn3hwrSjHSdAFdcAY38Tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088515; c=relaxed/simple; bh=H9ZTJz1mF5YSrJcLOXtHgxvectDIutM5qdUYktdCdCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nyPPRQmRRzb88H0tNZlXFSvZVScqoT7iUFS2iWrTdDbEUQ83WPKGhaZ8XqpUS5TxlD8DLn1xjYimeTl55aT9ySvQxk0AGCJVHG0f5FFibZgIcWhW/iu5JM3E9sdzToYX/7wTZGvcVX4917NEytUAJBrvgYii/gjTsVhdea3ujwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=drPuXw7W; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="drPuXw7W" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=bp/LIwK91vjxqQflXEqvF0xjrSazqceNniNex5W7jxA=; b=drPuXw7W98Dy1p790t8BmNy4vn dh8W/4jNZf6I1H5dAtjo2E84KDKEDfFeYeblpUoUKZzVpUiUKyXlIG3prWElNpysQC/bMqGM9hoZs JKngv7eZ9DUpaTqQu86otVVRWfc7aB0/icZe1nkc5Yizf3k3djoi/CwtMW4uFuJ/d9RZWbh5DCDv4 tJIJIY9znuafVLkC8n1VpXDNjnlnLDXUIMpmraGU856wRbe+dP+rnW7Mms0AR0vZr6GqyTJS7sD22 m6oq/6OXPncqh2quFsjYrDop75KYm4LCyywFB0ZPWeK1osc4MKod4V9m2loWkGUzgbgr91OBpU+88 FDS0aVPQ==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nG-000Mgf-0l; Tue, 22 Sep 2026 16:48:26 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nF-000PP0-2G; Tue, 22 Sep 2026 16:48:25 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 03/10] leds: pca995x: Fix maximum LED index for 16-channel variants Date: Tue, 22 Sep 2026 16:47:50 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) The pca995x_chipdef for the 16-channel variants PCA9952 and PCA9955B correctly sets num_leds to 16, but the value was not actually used when checking and iterating over the LEDs during probe. Fixes: 68d6520d2e76 ("leds: leds-pca995x: Add support for NXP PCA9956B") Link: https://sashiko.dev/#/patchset/6d3600f99c77c31166f0b6a5ccfb7f518b53c4= c9.1788350618.git.nora.schiffer@ew.tq-group.com Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index fee6216cd1bd0..8b05b3f12cf38 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -146,7 +146,7 @@ static int pca995x_probe(struct i2c_client *client) if (ret) return ret; =20 - if (reg < 0 || reg >=3D PCA995X_MAX_OUTPUTS || led_fwnodes[reg]) + if (reg < 0 || reg >=3D chipdef->num_leds || led_fwnodes[reg]) return -EINVAL; =20 led =3D &chip->leds[reg]; @@ -157,7 +157,7 @@ static int pca995x_probe(struct i2c_client *client) led->ldev.max_brightness =3D 255; } =20 - for (i =3D 0; i < PCA995X_MAX_OUTPUTS; i++) { + for (i =3D 0; i < chipdef->num_leds; i++) { struct led_init_data init_data =3D {}; =20 if (!led_fwnodes[i]) @@ -169,7 +169,7 @@ static int pca995x_probe(struct i2c_client *client) &chip->leds[i].ldev, &init_data); if (ret < 0) { - for (j =3D i; j < PCA995X_MAX_OUTPUTS; j++) + for (j =3D i; j < chipdef->num_leds; j++) fwnode_handle_put(led_fwnodes[j]); return dev_err_probe(dev, ret, "Could not register LED %s\n", --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FA48391E4C; Tue, 22 Sep 2026 14:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088517; cv=none; b=l1RR8PNTY6oK/1fobu8zvI83RhPJZzYM6a38z3BMShk0WFDCOkXb834bDNhlW7gaJXQfbk3J7WIn7Nz80QPULRsbP1vGsM1RLQ/WCF44u4DEgTxed1mL4yFOjOLtuN1xUt+/3afbirgh9bD8Sn7aqYpR7oupsQPsYyFK9eyUvcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088517; c=relaxed/simple; bh=47hb35oYe5cuVEEq7siJ4GEo+xFp7UzsM0cF6S9itXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EpNQ8W25xOZI+UlgyT3nRAf+Co3x74geuR1ZaUWGP9UetwTMvyi5JRixT4VX/qfycswP0UmFXRr87xkk8GRJ3k2lnDMajyOK70UBZ5AiG45vsxINtWSLIfgGys7FGFJCLG9G/igzlETPv6BVnesP7Kl+YZGAmRY7KW75U3oKZQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=dvq+FeiQ; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="dvq+FeiQ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=GMOJFlc4JrhNDRUMJSPF00oTxXHLgtst/iFJ7M3QOmg=; b=dvq+FeiQlW/c+ZQZeeZVQ5SeyB Kt97/3hH1g7KOC6Xgxdqw9UKqerCn+QbNmYOhkxEGuiAssBiFJ8C6/e3xI5Tg+KCE5psmJ5ao8Nnd a+/U15Id6gAoEl9od09nbDg+vX2ByBVx6yt36aO2odxPPuroPyTbz8oYNM4HS3L8Hv3/8X09BcVZn MMg5deuUDLH6oQ7UsJGPizrVFev73CqOn241L+DJl/ZVlPf+F+hI+KhlicBN9at3FpuANtuztwT4D WsxQT+O2G1XmOU5c3PrLEmFmm8D1KuVkLJOP174R/4cWg79rYN5uRl1VxfIaWK4U4+riVgFVBU+zG rjW/6wbw==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nG-000Mh1-25; Tue, 22 Sep 2026 16:48:26 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nG-000PP0-0M; Tue, 22 Sep 2026 16:48:26 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 04/10] leds: pca995x: Fix fwnode handle leaks in error paths Date: Tue, 22 Sep 2026 16:47:51 +0200 Message-ID: <3d38609c96d387aec7eaff7cdb19fc2d8eb32a3e.1790087890.git.nora.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) Each entry in led_fwnodes needs to be put as long as no LED device has been created for it yet - not just in the creation loop, but also in the first loop that iterates over the child nodes. By clearing entries in led_fwnodes once they have been used, the same cleanup loop can be used to handle errors in both loops. Fixes: 82c5ada1f9d0 ("leds: pca995x: Fix device child node usage in pca995x= _probe()") Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index 8b05b3f12cf38..079ce3d8f1e49 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -123,7 +123,7 @@ static int pca995x_probe(struct i2c_client *client) const struct pca995x_chipdef *chipdef; struct pca995x_chip *chip; struct pca995x_led *led; - int i, j, reg, ret; + int i, reg, ret; =20 chipdef =3D device_get_match_data(&client->dev); =20 @@ -144,10 +144,12 @@ static int pca995x_probe(struct i2c_client *client) device_for_each_child_node_scoped(dev, child) { ret =3D fwnode_property_read_u32(child, "reg", ®); if (ret) - return ret; + goto err_put_nodes; =20 - if (reg < 0 || reg >=3D chipdef->num_leds || led_fwnodes[reg]) - return -EINVAL; + if (reg < 0 || reg >=3D chipdef->num_leds || led_fwnodes[reg]) { + ret =3D -EINVAL; + goto err_put_nodes; + } =20 led =3D &chip->leds[reg]; led_fwnodes[reg] =3D fwnode_handle_get(child); @@ -169,12 +171,12 @@ static int pca995x_probe(struct i2c_client *client) &chip->leds[i].ldev, &init_data); if (ret < 0) { - for (j =3D i; j < chipdef->num_leds; j++) - fwnode_handle_put(led_fwnodes[j]); - return dev_err_probe(dev, ret, - "Could not register LED %s\n", - chip->leds[i].ldev.name); + dev_err_probe(dev, ret, "Could not register LED %s\n", + chip->leds[i].ldev.name); + goto err_put_nodes; } + + led_fwnodes[i] =3D NULL; } =20 /* Disable LED all-call address and set normal mode */ @@ -184,6 +186,12 @@ static int pca995x_probe(struct i2c_client *client) =20 /* IREF Output current value for all LEDn outputs */ return regmap_write(chip->regmap, chipdef->irefall, PCA995X_IREFALL_HALF_= CFG); + +err_put_nodes: + for (i =3D 0; i < chipdef->num_leds; i++) + fwnode_handle_put(led_fwnodes[i]); + + return ret; } =20 static const struct i2c_device_id pca995x_id[] =3D { --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CC0E391E4B; Tue, 22 Sep 2026 14:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088517; cv=none; b=E2x2R8n+lS5NV7r4OCaI6aRRIMiR0ODDNpP38JXb7pEGet96h8LH5mvv4j5b4GQgb1x4UZ8oatkYV5Wy9b9Dh0mPJHSJqhawjRMFVsOl6MTxa+D3oV6cuqgCXVTIJ6bOFOP7cggPvs4BY/sCGJ1PxHnBXcdt5a4aZSR5gXnzkMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088517; c=relaxed/simple; bh=fMsEYMaJ3Q4u7pflwE7/gzWXjChtDSHAJtkGAzMt7Wo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=evOhehaR4rZWjQg4P1mBPx5GUjJwIqQNBEzL6jEigH4f5vdH0oDrDHd2mOZyuGNMwbTgG9IdeLaCOo7jcBvp+ZIv0teAeI/3B2fbdmP5BIS6Wn5+TWEZO5OZkZbp48I0Oo9q2F/dWzYO3ZFoyg7ey54Kbg/ZTMh2Md5gx3GjK8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=VWytTBcT; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="VWytTBcT" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=KYuf12bt9LdGnasJY7HDXdK/vvJyApSn9sMWxpyDAoI=; b=VWytTBcT65pcdSLL5atzPErx79 re8pdZtgPKRCyDru3rKjYSFryZj4qw4GssLlTOS9a2LpMzTCNjX8nF03HS3jbyr06UDlW2CpX0s66 lObimfJ/TmjHyTLuT+jZfAKC3RMXybsirQONF+JG8CYRBprp8gbghL9hmQWucbJfG4/dZ3tVl/eX4 IPe5dZi3s1tFRBQ3EFYJv55TPvwWXc7bEyUcTZzehmV6ZPy3ozmIF0uimo8YXurEUCsHFnMzZ5aN6 ZomP8OdX0zjxNNWDsgazgIKNCypL2tZaygVEmNCWVyGNA5n029lY/gXpjrspUiKJ4I/dFsQ0MyJaW z6tTcE4w==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nH-000MhF-0A; Tue, 22 Sep 2026 16:48:27 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nG-000PP0-1d; Tue, 22 Sep 2026 16:48:26 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 05/10] leds: pca995x: Write global registers before creating LED devices Date: Tue, 22 Sep 2026 16:47:52 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) The hardware setup should be finished before the devices become visible to userspace. Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index 079ce3d8f1e49..e6122b33451ed 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -159,6 +159,16 @@ static int pca995x_probe(struct i2c_client *client) led->ldev.max_brightness =3D 255; } =20 + /* Disable LED all-call address and set normal mode */ + ret =3D regmap_write(chip->regmap, PCA995X_MODE1, PCA995X_MODE1_CFG); + if (ret) + goto err_put_nodes; + + /* IREF Output current value for all LEDn outputs */ + ret =3D regmap_write(chip->regmap, chipdef->irefall, PCA995X_IREFALL_HALF= _CFG); + if (ret) + goto err_put_nodes; + for (i =3D 0; i < chipdef->num_leds; i++) { struct led_init_data init_data =3D {}; =20 @@ -179,13 +189,7 @@ static int pca995x_probe(struct i2c_client *client) led_fwnodes[i] =3D NULL; } =20 - /* Disable LED all-call address and set normal mode */ - ret =3D regmap_write(chip->regmap, PCA995X_MODE1, PCA995X_MODE1_CFG); - if (ret) - return ret; - - /* IREF Output current value for all LEDn outputs */ - return regmap_write(chip->regmap, chipdef->irefall, PCA995X_IREFALL_HALF_= CFG); + return 0; =20 err_put_nodes: for (i =3D 0; i < chipdef->num_leds; i++) --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84C77392802; Tue, 22 Sep 2026 14:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; cv=none; b=av9Gfs3qFh4w1R4DCpvA0uuiADvrcQe3YHFvJFg/dxeRDTUp5K0dVNiaEeFRiGnAKJkEEBISLID2ir7hmG/w9kQ+FIrPd5CMQAUmUWX9LAugmdPo1LCEAmmXgK2uISpjh1PJ4jorJqKE/JJjezAW1rathYvKVtnBaSqPwCcGZj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; c=relaxed/simple; bh=x34LHTwBatjlELoJlVjVjMc0ih2t5zfVwePL41nvduw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kvxr8oUYtQki/PJpAsh7nCWLUpnzi1kHJl50gphD9WGaP0mnuEc5itG23DTSFySkLI/ksgi7iV0ryRTAzHkSsc+ZvDmyajPGlyJqiDTq3QMDn/v5SfCL9Us5JBF1VWjScIL4FWPSzx0nfgm4KOPOEYoq2DCQ7RXXruLA1Qv0tso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=ohdgG/FH; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="ohdgG/FH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=7/9j/ZIB/tsoCyWFj5gYto+ZmNGdvuaACBD0+J0poL0=; b=ohdgG/FH1SlqU1ZYDrsXqlNBbM Dps89idW2tQlxLalfqGhFW3ooGw7fOaN+XibMRPTes5QhDgvaiX1dhlmESxq7QlANcb1I6URKApRo gxLFS0hV90VkRFK4SwWveBI5OxYTGVbhuLDHnvCcmKZhywV6IYJFkma2FIj6kVNVihQgGbc332CxK jJHhYH7vTwTp+vObrTPNszn8HkqtKFfeZJWJxlx0OIvsgbH7e1mBbQdtos7KnZOmfXi7dFHmR2I7I bQaubwyPno/zEoalw6ADCazsIuTj4c0W9usL9/mmA7jjF9nkbH4eVe/rZJH7BlXfWF3YnqrGWzXVM NJu+oFGA==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nH-000Mhm-1a; Tue, 22 Sep 2026 16:48:27 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nG-000PP0-2s; Tue, 22 Sep 2026 16:48:26 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 06/10] leds: pca995x: Add support for reset GPIO Date: Tue, 22 Sep 2026 16:47:53 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) The PCA9952/9955B/9956B have a reset pin. Use it to reset the LED driver if provided in the Device Tree. Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index e6122b33451ed..b528b2b4990a7 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -8,6 +8,8 @@ * Copyright 2023 Marek Vasut */ =20 +#include +#include #include #include #include @@ -121,6 +123,7 @@ static int pca995x_probe(struct i2c_client *client) struct fwnode_handle *led_fwnodes[PCA995X_MAX_OUTPUTS] =3D { 0 }; struct device *dev =3D &client->dev; const struct pca995x_chipdef *chipdef; + struct gpio_desc *reset_gpio; struct pca995x_chip *chip; struct pca995x_led *led; int i, reg, ret; @@ -130,6 +133,16 @@ static int pca995x_probe(struct i2c_client *client) if (!dev_fwnode(dev)) return -ENODEV; =20 + reset_gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(reset_gpio)) + return dev_err_probe(dev, PTR_ERR(reset_gpio), + "failed to request reset GPIO\n"); + if (reset_gpio) { + udelay(3); + gpiod_set_value_cansleep(reset_gpio, 0); + usleep_range(1500, 1600); + } + chip =3D devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C742638F95A; Tue, 22 Sep 2026 14:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088517; cv=none; b=atiJ+zNkKKflrC5krNxboVphKNMgQmCtIC3eJFPN7U3AVH5eDx2zRH2Nk6xSh2e63vRowdues18DxfZjGAzb0tiIyVZymVBOQAQF1iBQHjMOno/fvs/RcrYg06G17lVlk2Gh51G+yH5nLFVPLIlmBzM2ItRkGjFIyeKIsIYOZsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088517; c=relaxed/simple; bh=FCApGHMWc+kTIV27sY3rCeuIozsTpc3FMQYww0bbJu0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=csMt5yxFLQC7sae0AfSR7YfqT/j+/WTzV9DIU8nTCXCPjR6D2ZqGI09mTJqNhBzkq7ptBJEpWTKdaomMsYp/+oQFmzzQz7bdH+nRmh9kcqlshTtHgXuRYh9n+RxAc/qo6HrIW3YqE7GE87AF2OiqUqiY8qin6y92QTRaxPyPE6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=b+v7mGRH; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="b+v7mGRH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=zvOgkVbLTZAACB9gDj+VHjZkJMYpe7K5p8sFuAHu5Rc=; b=b+v7mGRH48sfl5qmUgK0XXSXWn fo8NRE0qiOl52Iqc72CEIZ8Hc0EbfFs/u3kLy3u4ylzZ174Wnh5sd7YckQm/J4FBBPyFu6FbNgTfE HeVNySI+kcMcVMgiR6YpYq9VvPVQpjvifwVYc9iZwt1b39qSVHgxzU4sV+FA3G2JodIdckH+9fWH9 23SNxWESYye9K6Mm56JgjaXo0CUtazkHMZmq+BTzkkB4Todg32sRbN4U0VGuTvdrIcyTyn2csvwuy phJp6XyhJewvhexhLk5UieuZqo6+NNUS1gfbjXktkvR7DDiicczeeuG7RyGLiDhiL5ond/LkkvHVj rCyb0MLQ==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nH-000MiJ-2Z; Tue, 22 Sep 2026 16:48:27 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nH-000PP0-0w; Tue, 22 Sep 2026 16:48:27 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 07/10] leds: pca995x: Make output gain configurable Date: Tue, 22 Sep 2026 16:47:54 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) The output gain linearly configures the LED current in 255 levels; the absolute current depends on both the gain value and the R_ext resistor connected to the LED driver. Make the gain configurable in the Device Tree instead of hardcoding it to 128, allowing to adjust the current for different hardware designs. Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index b528b2b4990a7..13cce0c3fdc19 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -127,6 +127,7 @@ static int pca995x_probe(struct i2c_client *client) struct pca995x_chip *chip; struct pca995x_led *led; int i, reg, ret; + u32 iref; =20 chipdef =3D device_get_match_data(&client->dev); =20 @@ -154,6 +155,11 @@ static int pca995x_probe(struct i2c_client *client) =20 i2c_set_clientdata(client, chip); =20 + if (device_property_read_u32(dev, "nxp,output-gain", &iref)) + iref =3D PCA995X_IREFALL_HALF_CFG; + else if (iref > PCA995X_IREFALL_FULL_CFG) + return dev_err_probe(dev, -EINVAL, "invalid nxp,output-gain\n"); + device_for_each_child_node_scoped(dev, child) { ret =3D fwnode_property_read_u32(child, "reg", ®); if (ret) @@ -178,7 +184,7 @@ static int pca995x_probe(struct i2c_client *client) goto err_put_nodes; =20 /* IREF Output current value for all LEDn outputs */ - ret =3D regmap_write(chip->regmap, chipdef->irefall, PCA995X_IREFALL_HALF= _CFG); + ret =3D regmap_write(chip->regmap, chipdef->irefall, iref); if (ret) goto err_put_nodes; =20 --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8AB73911D6; Tue, 22 Sep 2026 14:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088518; cv=none; b=qKvbePvptBhPQlZdfU7T7bNg7TCLb11EJVxchO/UW8clSGClNWpm5XsK4k7lm3l3D6+hiBsIjAUp62cDq7hEv7sk7kNJEg0YOWLISo/+WhLIZSAzVp0uUFJeeRacprCBQfGVFQNDmpPJKve8LrUcz0tTaAEjPoTeV00c85AhIJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088518; c=relaxed/simple; bh=Aq1pLEdqVsyPCq7NAajxaF/25xutVxMfutUIWD7qBds=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QbCjQ8FrdngdVVciICWjzJhH1WsQsVj7MUk5wFr6DGwdVD/avbr+p5HgI1Ko4tDGI1pLc1wJdULeifw2KDmSb3KUKXoWDe0bTiv3j2+ocKhYkc6VQ75gyCK/MaThb9ci3KO+OqUMKQkthhMO/h7KGxRRh5D69FeLsnaeoYeA0HU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=miN1jFQ6; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="miN1jFQ6" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=j8v1elqs7zW00gnUpHmNxsDqCTyeBmas5xfMBDnBJOg=; b=miN1jFQ627EFgeQhrQzJhSzVnu RUt0wDO+Z0s8pbXO9UpHTKLhibCQFm3oYP9tk8rvr/m8d0XjLHsgO095pFRuAaBMv31lnhYdQ4Onk qjiWB5YKgomsu/mRR8hPjmUTT3hFxDn3U0+VFWzK5Z2u4KhIXTEue+IRydM9hcqf9o+eUCZCdHl+7 2ZLxQdDsqGkw6yfwSzCXxh03YLHdOVgXMNcQVcBy73LSAxqqmfvQ6DaMBU2F+0d7FPXXBuB3Nkw7s 6LI8yZK7PsoiC9XZgpQy6jWEK4+EhTd4KPeSXMpCjJRww0Y2gJng41Yty8yQ2xu9wHrZVRU8Uk1pB +gLSjTew==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nI-000Mih-0d; Tue, 22 Sep 2026 16:48:28 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nH-000PP0-2A; Tue, 22 Sep 2026 16:48:27 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 08/10] leds: pca995x: Add sysfs files for error reporting Date: Tue, 22 Sep 2026 16:47:55 +0200 Message-ID: <9c5bb10d247abc5acb752a4b884c2c3612abecdb.1790087890.git.nora.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) The PCA995x has builtin failure detection. Provide sysfs files for individual LED status (reporting "okay", "short-circuit" or "open-circuit") as well as a global "has_errors" flag. has_errors is sticky and must be cleared by writing "clear" to the sysfs file. Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 112 +++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index 13cce0c3fdc19..57b5d2d6e035d 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -8,6 +8,7 @@ * Copyright 2023 Marek Vasut */ =20 +#include #include #include #include @@ -24,6 +25,12 @@ /* Auto-increment disabled. Normal mode */ #define PCA995X_MODE1_CFG 0x00 =20 +#define PCA995X_MODE2_CLRERR BIT(4) +#define PCA995X_MODE2_ERROR BIT(6) + +/* Clear errors on probe, group brightness control, linear adjustment */ +#define PCA995X_MODE2_CFG PCA995X_MODE2_CLRERR + /* LED select registers determine the source that drives LED outputs */ #define PCA995X_LED_OFF 0x0 #define PCA995X_LED_ON 0x1 @@ -37,30 +44,37 @@ #define PCA995X_IREFALL_FULL_CFG 0xFF #define PCA995X_IREFALL_HALF_CFG (PCA995X_IREFALL_FULL_CFG / 2) =20 +#define PCA995X_EFLAG_BITS 2 +#define PCA995X_EFLAG_MASK GENMASK(1, 0) + #define ldev_to_led(c) container_of(c, struct pca995x_led, ldev) =20 struct pca995x_chipdef { unsigned int num_leds; u8 pwm_base; u8 irefall; + u8 eflag_base; }; =20 static const struct pca995x_chipdef pca9952_chipdef =3D { .num_leds =3D 16, .pwm_base =3D 0x0a, .irefall =3D 0x43, + .eflag_base =3D 0x44, }; =20 static const struct pca995x_chipdef pca9955b_chipdef =3D { .num_leds =3D 16, .pwm_base =3D 0x08, .irefall =3D 0x45, + .eflag_base =3D 0x46, }; =20 static const struct pca995x_chipdef pca9956b_chipdef =3D { .num_leds =3D 24, .pwm_base =3D 0x0a, .irefall =3D 0x40, + .eflag_base =3D 0x41, }; =20 struct pca995x_led { @@ -112,6 +126,83 @@ static int pca995x_brightness_set(struct led_classdev = *led_cdev, } } =20 +static ssize_t status_show(struct device *dev, struct device_attribute *at= tr, char *buf) +{ + struct led_classdev *led_cdev =3D dev_get_drvdata(dev); + struct pca995x_led *led =3D ldev_to_led(led_cdev); + struct pca995x_chip *chip =3D led->chip; + const struct pca995x_chipdef *chipdef =3D chip->chipdef; + const char *status =3D "unknown"; + unsigned int val; + int shift, ret; + u8 reg; + + reg =3D chipdef->eflag_base + (led->led_no / PCA995X_OUTPUTS_PER_REG); + shift =3D PCA995X_EFLAG_BITS * (led->led_no % PCA995X_OUTPUTS_PER_REG); + + ret =3D regmap_read(chip->regmap, reg, &val); + if (ret) + return ret; + + switch ((val >> shift) & PCA995X_EFLAG_MASK) { + case 0: + status =3D "okay"; + break; + case 1: + status =3D "short-circuit"; + break; + case 2: + status =3D "open-circuit"; + } + + return sysfs_emit(buf, "%s\n", status); +} + +static DEVICE_ATTR_RO(status); + +static struct attribute *pca995x_led_attrs[] =3D { + &dev_attr_status.attr, + NULL, +}; +ATTRIBUTE_GROUPS(pca995x_led); + +static ssize_t has_errors_show(struct device *dev, struct device_attribute= *attr, char *buf) +{ + struct pca995x_chip *chip =3D i2c_get_clientdata(to_i2c_client(dev)); + unsigned int val; + int ret; + + ret =3D regmap_read(chip->regmap, PCA995X_MODE2, &val); + if (ret) + return ret; + + + return sysfs_emit(buf, "%d\n", !!(val & PCA995X_MODE2_ERROR)); +} + +static ssize_t has_errors_store(struct device *dev, struct device_attribut= e *attr, + const char *buf, size_t count) +{ + struct pca995x_chip *chip =3D i2c_get_clientdata(to_i2c_client(dev)); + int ret; + + if (!sysfs_streq(buf, "clear")) + return -EINVAL; + + ret =3D regmap_update_bits(chip->regmap, PCA995X_MODE2, + PCA995X_MODE2_CLRERR, PCA995X_MODE2_CLRERR); + + return ret ?: count; +} + +static DEVICE_ATTR_RW(has_errors); + +static struct attribute *pca995x_attrs[] =3D { + &dev_attr_has_errors.attr, + NULL, +}; +ATTRIBUTE_GROUPS(pca995x); + static const struct regmap_config pca995x_regmap =3D { .reg_bits =3D 8, .val_bits =3D 8, @@ -176,6 +267,7 @@ static int pca995x_probe(struct i2c_client *client) led->led_no =3D reg; led->ldev.brightness_set_blocking =3D pca995x_brightness_set; led->ldev.max_brightness =3D 255; + led->ldev.groups =3D pca995x_led_groups; } =20 /* Disable LED all-call address and set normal mode */ @@ -183,11 +275,20 @@ static int pca995x_probe(struct i2c_client *client) if (ret) goto err_put_nodes; =20 + /* Clear errors on probe */ + ret =3D regmap_write(chip->regmap, PCA995X_MODE2, PCA995X_MODE2_CFG); + if (ret) + goto err_put_nodes; + /* IREF Output current value for all LEDn outputs */ ret =3D regmap_write(chip->regmap, chipdef->irefall, iref); if (ret) goto err_put_nodes; =20 + ret =3D device_add_groups(dev, pca995x_groups); + if (ret) + goto err_put_nodes; + for (i =3D 0; i < chipdef->num_leds; i++) { struct led_init_data init_data =3D {}; =20 @@ -202,7 +303,7 @@ static int pca995x_probe(struct i2c_client *client) if (ret < 0) { dev_err_probe(dev, ret, "Could not register LED %s\n", chip->leds[i].ldev.name); - goto err_put_nodes; + goto err_remove_groups; } =20 led_fwnodes[i] =3D NULL; @@ -210,6 +311,9 @@ static int pca995x_probe(struct i2c_client *client) =20 return 0; =20 +err_remove_groups: + device_remove_groups(dev, pca995x_groups); + err_put_nodes: for (i =3D 0; i < chipdef->num_leds; i++) fwnode_handle_put(led_fwnodes[i]); @@ -217,6 +321,11 @@ static int pca995x_probe(struct i2c_client *client) return ret; } =20 +static void pca995x_remove(struct i2c_client *client) +{ + device_remove_groups(&client->dev, pca995x_groups); +} + static const struct i2c_device_id pca995x_id[] =3D { { .name =3D "pca9952", .driver_data =3D (kernel_ulong_t)&pca9952_chipdef = }, { .name =3D "pca9955b", .driver_data =3D (kernel_ulong_t)&pca9955b_chipde= f }, @@ -239,6 +348,7 @@ static struct i2c_driver pca995x_driver =3D { .of_match_table =3D pca995x_of_match, }, .probe =3D pca995x_probe, + .remove =3D pca995x_remove, .id_table =3D pca995x_id, }; module_i2c_driver(pca995x_driver); --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8BDE3932E5; Tue, 22 Sep 2026 14:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088518; cv=none; b=ESwU5E/hj/liFu6QjEyxs+i7zJY5qSV9oUQHejkYVcH4zmQ9I6NOVgqegiOkJSF/LPKLrTU6gqDwi2rAriERB02LW9f3RSb7W+Xud1HvdTZNLxHk9HOvBepwgjmYK85dmxxExoczIAead5JRG03sRX+GCc/7n+vFO6MGbIa/2wE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088518; c=relaxed/simple; bh=J39ctggg4+o3oRV6PV/FJs5F2Jnk1Zj6qONzpvoRt64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F4HFjC7/flnt8BstU54OQa27mEmSzywKTQJbZlpDqrAUbcpMYJ+RMEWGBzHHELPnWoFzQXcYOAOt+EJLa2Gp3EDNb6+AbVg73f0A6vdOg64vl6TwlCAX3oa/yF/Mimnv5fGObL7hDB80gKdTq0gbc0GfumkjZ/WmLDjyzxwy1a8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=k6ZhoQZS; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="k6ZhoQZS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=13B7QLUFJtdjEEsKoyqV6NO0BscoDwNdJPCtxIr1RBM=; b=k6ZhoQZSI44KQ/qoIMxjZQTm5J hS81C2feRFKdReAf6h0UDFJ54pDXY5HznJknscK3yfBZzsKb/wV6rXB7AA/4IcNwl2QHkBGBwBE2m giqfdDo6xxC5+wjQUqVirFTVS1REQ05VnORleZyuwbLBDVktfgMKFj3zp3JNnp255zYGMT09nisbs +BrMouG1nOlVoOH0VgpnoQA54bHQfLq3p9yVVQDKThbTseDSaqUKU7LrPLm0n7L4uStJqtEAjdde3 NVJegnPUdxlz/iRCFi4HnWPZrEQJhPEED/OeWdmbp1AC/ABM88bbPOgAtmvTWYQO+ak0mCBtdNMp/ oz2dSHtA==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nI-000MjF-1x; Tue, 22 Sep 2026 16:48:28 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nI-000PP0-0H; Tue, 22 Sep 2026 16:48:28 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 09/10] leds: pca995x: Do not use full on LED mode Date: Tue, 22 Sep 2026 16:47:56 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) LEDs in full on mode are unaffected by group dimming. Avoid using it, so group dimming is applied consistently. This slightly changes the brightness at maximum (from 100% to 255/256 duty cycle), which should be imperceptible; arguably it is also more consistent with the other brightness levels, as it will now scale linearly from 0/256 to 255/256 over the whole range. Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index 57b5d2d6e035d..61d2581b976ce 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -102,28 +102,23 @@ static int pca995x_brightness_set(struct led_classdev= *led_cdev, ledout_addr =3D PCA995X_LEDOUT0 + (led->led_no / PCA995X_OUTPUTS_PER_REG); shift =3D PCA995X_LDRX_BITS * (led->led_no % PCA995X_OUTPUTS_PER_REG); =20 - switch (brightness) { - case LED_FULL: - return regmap_update_bits(chip->regmap, ledout_addr, - PCA995X_LDRX_MASK << shift, - PCA995X_LED_ON << shift); - case LED_OFF: + if (brightness =3D=3D LED_OFF) { return regmap_update_bits(chip->regmap, ledout_addr, PCA995X_LDRX_MASK << shift, 0); - default: - /* Adjust brightness as per user input by changing individual PWM */ - ret =3D regmap_write(chip->regmap, pwmout_addr, brightness); - if (ret) - return ret; - - /* - * Change LDRx configuration to individual brightness via PWM. - * LED will stop blinking if it's doing so. - */ - return regmap_update_bits(chip->regmap, ledout_addr, - PCA995X_LDRX_MASK << shift, - PCA995X_LED_PWM_MODE << shift); } + + /* Adjust brightness as per user input by changing individual PWM */ + ret =3D regmap_write(chip->regmap, pwmout_addr, brightness); + if (ret) + return ret; + + /* + * Change LDRx configuration to individual brightness via PWM. + * LED will stop blinking if it's doing so. + */ + return regmap_update_bits(chip->regmap, ledout_addr, + PCA995X_LDRX_MASK << shift, + PCA995X_LED_PWM_MODE << shift); } =20 static ssize_t status_show(struct device *dev, struct device_attribute *at= tr, char *buf) --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/ From nobody Thu Sep 24 15:10:13 2026 Received: from www537.your-server.de (www537.your-server.de [188.40.3.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B7F9390C9F; Tue, 22 Sep 2026 14:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=188.40.3.216 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; cv=none; b=m2lywStsxcBDFDdvXdZhrTuBxdUk7a4VNA/C+rOMvkZpDMLpMJfPrO+r0akOxz5Ob1aq/AEsD+VMscm98PprmjbJ43sIvqgbdI6yKkgnEdXjYDHAgi1t9VV2JRCHdg4QaHS/4+rO1G7k6sVvaECzXfXdqiLMhdo0deaetVdxtYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790088516; c=relaxed/simple; bh=J5UELDGENmNNqWRPc/yVaZ1V8n9iLRRrh1kw4xy+rP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t1+S24ugCeNrt2EzgKNuGgcLeHjrjQ/gTcMNfzIDMVEqEd/ScmPqn+c/mDb3ypJD0Z3GhbIn4ch/NzRJcjVN9d8kR7NVVt/php2leOfLiKX3Rb6Z3e+zmtclmZugLIX9Zf7GAix1fm0HE6WleJYrB329u8CJs0tfHUNh8OWOcDI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=IcP8UguM; arc=none smtp.client-ip=188.40.3.216 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="IcP8UguM" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ew.tq-group.com; s=default2602; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=23ar66KXjAiEQWtcp86Qmj9HMDunfCZrhtY90Rq8AJg=; b=IcP8UguM8osU4wYCe0WkvWD76U d5ASylOQl7yPSFAboRqISdDo1Qf4Q9klP16lu8NI/eGHdWFI0c+C9PZrSqZrzTwhLUlenuJEUFGoi cQhtVZP4VH6caTcNeD9lYJwiy1P3la+rIKGt/TratCbRO/oy7lQzmXhYjDB1q0K35R4o4i4zjQ7JP y9tR1t4tGgWKtKPquAu9AcehOxSQkwVXIun34/+svz2XANVi/Oy92cPLgbQ6m8ABLFyV1Cb+8G5kC y3983NiQajAfKUxyDW71VvwBomvzghW6u/leEnW301KquxNlureiqbMpwqbNi02IY8nSGU14QMRdg nCy9TKOA==; Received: from sslproxy02.your-server.de ([78.47.166.47]) by www537.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1x91nM-000Ml1-12; Tue, 22 Sep 2026 16:48:32 +0200 Received: from localhost ([127.0.0.1]) by sslproxy02.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x91nI-000PP0-1a; Tue, 22 Sep 2026 16:48:28 +0200 From: Nora Schiffer To: Lee Jones , Pavel Machek Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Isai Gaspar , Marek Vasut , Pieterjan Camerlynck , Javier Carrasco , linux@ew.tq-group.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nora Schiffer Subject: [PATCH v3 10/10] leds: pca995x: Add support for group brightness control Date: Tue, 22 Sep 2026 16:47:57 +0200 Message-ID: <391973ce0168438612861bfe8570b6890af0f44e.1790087890.git.nora.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Clear (ClamAV 1.4.3/28131/Tue Sep 22 08:27:06 2026) When LEDs are set to PWM mode with group control enabled, their brightness can control using a global "group PWM" setting, modulating the individual LEDs' brightness with a second PWM running at a different frequency. This lowers the minimum duty cycle from 1/256 to 1/65536 (averaged over the modulated signal). Group brightness control is particularly useful to adjust for different levels of ambient light. For simplicity, group PWM mode is always enabled, with the reset default of 255 as group brightness. This reduces the effective duty cycle by 1/256 at all individual brightness levels (the individual PWM signals are modulated with the 255/256 duty cycle group PWM), which should be imperceptible. Signed-off-by: Nora Schiffer --- drivers/leds/leds-pca995x.c | 46 ++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c index 61d2581b976ce..d6438b576b186 100644 --- a/drivers/leds/leds-pca995x.c +++ b/drivers/leds/leds-pca995x.c @@ -35,6 +35,7 @@ #define PCA995X_LED_OFF 0x0 #define PCA995X_LED_ON 0x1 #define PCA995X_LED_PWM_MODE 0x2 +#define PCA995X_LED_PWM_MODE_GRP 0x3 #define PCA995X_LDRX_MASK 0x3 #define PCA995X_LDRX_BITS 2 =20 @@ -52,6 +53,7 @@ struct pca995x_chipdef { unsigned int num_leds; u8 pwm_base; + u8 grppwm; u8 irefall; u8 eflag_base; }; @@ -59,6 +61,7 @@ struct pca995x_chipdef { static const struct pca995x_chipdef pca9952_chipdef =3D { .num_leds =3D 16, .pwm_base =3D 0x0a, + .grppwm =3D 0x08, .irefall =3D 0x43, .eflag_base =3D 0x44, }; @@ -66,6 +69,7 @@ static const struct pca995x_chipdef pca9952_chipdef =3D { static const struct pca995x_chipdef pca9955b_chipdef =3D { .num_leds =3D 16, .pwm_base =3D 0x08, + .grppwm =3D 0x06, .irefall =3D 0x45, .eflag_base =3D 0x46, }; @@ -73,6 +77,7 @@ static const struct pca995x_chipdef pca9955b_chipdef =3D { static const struct pca995x_chipdef pca9956b_chipdef =3D { .num_leds =3D 24, .pwm_base =3D 0x0a, + .grppwm =3D 0x08, .irefall =3D 0x40, .eflag_base =3D 0x41, }; @@ -114,11 +119,10 @@ static int pca995x_brightness_set(struct led_classdev= *led_cdev, =20 /* * Change LDRx configuration to individual brightness via PWM. - * LED will stop blinking if it's doing so. */ return regmap_update_bits(chip->regmap, ledout_addr, PCA995X_LDRX_MASK << shift, - PCA995X_LED_PWM_MODE << shift); + PCA995X_LED_PWM_MODE_GRP << shift); } =20 static ssize_t status_show(struct device *dev, struct device_attribute *at= tr, char *buf) @@ -190,10 +194,41 @@ static ssize_t has_errors_store(struct device *dev, s= truct device_attribute *att return ret ?: count; } =20 +static ssize_t group_brightness_show(struct device *dev, struct device_att= ribute *attr, char *buf) +{ + struct pca995x_chip *chip =3D i2c_get_clientdata(to_i2c_client(dev)); + unsigned int val; + int ret; + + ret =3D regmap_read(chip->regmap, chip->chipdef->grppwm, &val); + if (ret) + return ret; + + return sysfs_emit(buf, "%u\n", val); +} + +static ssize_t group_brightness_store(struct device *dev, struct device_at= tribute *attr, + const char *buf, size_t count) +{ + struct pca995x_chip *chip =3D i2c_get_clientdata(to_i2c_client(dev)); + u8 val; + int ret; + + ret =3D kstrtou8(buf, 0, &val); + if (ret) + return ret; + + ret =3D regmap_write(chip->regmap, chip->chipdef->grppwm, val); + + return ret ?: count; +} + static DEVICE_ATTR_RW(has_errors); +static DEVICE_ATTR_RW(group_brightness); =20 static struct attribute *pca995x_attrs[] =3D { &dev_attr_has_errors.attr, + &dev_attr_group_brightness.attr, NULL, }; ATTRIBUTE_GROUPS(pca995x); @@ -270,11 +305,16 @@ static int pca995x_probe(struct i2c_client *client) if (ret) goto err_put_nodes; =20 - /* Clear errors on probe */ + /* Clear errors on probe, use GRPPWM register for group brightness contro= l */ ret =3D regmap_write(chip->regmap, PCA995X_MODE2, PCA995X_MODE2_CFG); if (ret) goto err_put_nodes; =20 + /* Full group brightness */ + ret =3D regmap_write(chip->regmap, chipdef->grppwm, U8_MAX); + if (ret) + goto err_put_nodes; + /* IREF Output current value for all LEDn outputs */ ret =3D regmap_write(chip->regmap, chipdef->irefall, iref); if (ret) --=20 TQ-Systems GmbH | M=C3=BChlstra=C3=9Fe 2, Gut Delling | 82229 Seefeld, Germ= any Amtsgericht M=C3=BCnchen, HRB 105018 Gesch=C3=A4ftsf=C3=BChrer: Detlef Schneider, R=C3=BCdiger Stahl, Stefan Sch= neider https://www.tq-group.com/