From nobody Sat Feb 7 17:55:50 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2728E1DE8AF for ; Sun, 21 Dec 2025 04:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766290831; cv=none; b=O0b7US8A09y4BXRAJeiQQZ1bSSwk8m71RdxFNrZ61PNnIAd6EVX6wH2PWocNb4GhYdRVPY8o43y7qsUd0nIUDwuqwjjNfGZpoD6liRaIa0Mr+UBoJFMFhVnLKa31uym6BfDJm7+sSd8V8sr2jRnSqGfxKkTy9nCwD3IIkaikaw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766290831; c=relaxed/simple; bh=kxvIpbUgvslFpHuyxurwqgQcXHL029H34uofMySvB2E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RfgIu3MQF8DDbY774ZPNNTsYyAWHCF5VlHq4MfLT8tGzp34wur+uN4oFvsu5WfUkN7BNpjs8LQVtB8hTMuZlarMCpMSnrJqhnz6N7f/CmEuHlxGe5Yzz8Y5ABMxGCR9PVEIHK14pQWVFL7jAy+k03wh6hjDl0S+zZceDAvNpkXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JabZMid0; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JabZMid0" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2a0d67f1877so37242885ad.2 for ; Sat, 20 Dec 2025 20:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766290827; x=1766895627; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e3unxyl0KTpbTfaWEmAlF0bEaP21z5y6mnXhjxR3yaQ=; b=JabZMid0iNDhd2sLQ1toCSHe+9YHtfwaEKIADQyrhG7qR+iom9+ApxMEDhF7Sl69qf YRClinjP+JIfNEIZEMUn1W2xXrqBjsB7+jU8vYwWdw1AS1s0mndw45eLLAVAr0j5BiVB BafQ49mhw+MuSp/Bo7CAD50k+EDqrDaODTXBrV2b1rCntSfGCQDf5doywZ0055uBt2Sw Jt7MKxeS2PNG/qAicewWVM0QS7jf8QVjKK7F87UT4qH0L6AJErEInTePCxY9JTh2ABV+ Tvl1u+h2X9kU9RdpiDzg61HGHBznqeUEhluHjRclvK3v1qqWVEV+vnOfUV377oXQ4yOf Mbjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766290827; x=1766895627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e3unxyl0KTpbTfaWEmAlF0bEaP21z5y6mnXhjxR3yaQ=; b=isweijDFbuQ7amJpmwiEaAcC6NJfeibF0xiI5OxhQcIroYLDx9lq8Q9aI25b+zDgdb KtGEbsX4x9uNeGVxPPhhfTcycZUif2OdOlOPd7uBeMP+4eOEnEKnsO0F1WkIDA7Wz81q HNFawWskN8J282wXJvHRI0L/mvUNGdaal2PNHdtdeNZR6kj6+B6VYxRNb0Ygusfyv4i+ 1Y0EOfE+0fgmQzJHW5AtZBZMvjz6qOWrwnyE4yohswvHwooBLRT5raLYnCN7NYpRtcpx T7mKAnI18deOCQZ64Vkcb2exBp4eBw+Y1qc5WaB/sZW5iJnA4ag7GXt2drs1rBLRhRUO yqTA== X-Forwarded-Encrypted: i=1; AJvYcCVYy0jEIZhYEVBvs7lbHHUmn5fR1LwJR9L8WA/r98TblrTMxk5CYF+X/z44tnOiz1MJ/agkUW0uyUk7ID0=@vger.kernel.org X-Gm-Message-State: AOJu0Yyu7n2I4Lj+p6LZMA1zfbfoORdoj1nJ9Fe7EYjVwscVI6D6hTRO FKKI8iCDMsO8WXa56cy+6l2VbJYwSvW5MDS04tVL5ID/fn2X1CtB+jj5 X-Gm-Gg: AY/fxX5J+ZfX3wLVukNoJUw5662s7/G1mqBSLXzRkivNFAhRsoMzcmYFLWNaxRaLWaH Ar5GxAWdGQWI6Sxc1OjCBVZbSPbgFO9Fi3UKAbVtkhAXDsragl33yTrlDhj7bHUXT+eU5HKgOGQ 3ZIDzuQW3DK52ez5zr0Ro44qLLU3a6iLEnqLp/K4QEVbKlX8KENQJshJk/ZBP/u+Z4SNrPnTF/z CGP7OlQ0MMfbPlwE8fUkG5qqNG0ebAcBCOTcE82fLkW1w0qmOO5SSGVNuL9dbOHLjqOG3ce+Zxu FYpk3XKjagpSkDgYx8iuhB9OwMq0NrGxJbHTS7mgGyqyTRmLL13ULk31GJRsVB8VtLgVHFQ4TC3 Wg2ZvIUBYwgAJxbpwVZ55qWitKbPPwtSn47YPkJa4OjlCpxfx8zbxvuvrVK8IjMz3MMpbm9QMpB RqWwAPCqo6OWzc7XVRBH+cLzziDZPq4n288Q== X-Google-Smtp-Source: AGHT+IFztACcGCaNDp2RZ/Gb4OUoZiBRSASJSq9iKgv66pH4oWOR55ktnOK9hdLDA4b3P7FCZyfNkA== X-Received: by 2002:a17:902:e552:b0:2a0:8360:3a74 with SMTP id d9443c01a7336-2a2f2835cfdmr55972695ad.51.1766290827400; Sat, 20 Dec 2025 20:20:27 -0800 (PST) Received: from localhost.localdomain ([14.255.43.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3d4cb90sm62319245ad.51.2025.12.20.20.20.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Dec 2025 20:20:26 -0800 (PST) From: Nam Tran To: lee@kernel.org Cc: pavel@kernel.org, gregkh@linuxfoundation.org, rdunlap@infradead.org, christophe.jaillet@wanadoo.fr, krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org, corbet@lwn.net, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, Nam Tran Subject: [PATCH v20 1/3] dt-bindings: leds: add TI/National Semiconductor LP5812 LED Driver Date: Sun, 21 Dec 2025 11:19:48 +0700 Message-Id: <20251221041950.4631-2-trannamatk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251221041950.4631-1-trannamatk@gmail.com> References: <20251221041950.4631-1-trannamatk@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The LP5812 is a 4x3 RGB LED driver with an autonomous animation engine and time-cross-multiplexing (TCM) support for up to 12 LEDs or 4 RGB LEDs. It supports both analog (256 levels) and PWM (8-bit) dimming, including exponential PWM for smooth brightness control. Reviewed-by: Rob Herring (Arm) Signed-off-by: Nam Tran --- .../devicetree/bindings/leds/ti,lp5812.yaml | 246 ++++++++++++++++++ MAINTAINERS | 6 + 2 files changed, 252 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/ti,lp5812.yaml diff --git a/Documentation/devicetree/bindings/leds/ti,lp5812.yaml b/Docume= ntation/devicetree/bindings/leds/ti,lp5812.yaml new file mode 100644 index 000000000000..de34bff441c7 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/ti,lp5812.yaml @@ -0,0 +1,246 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/ti,lp5812.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI LP5812 4x3 Matrix RGB LED Driver with Autonomous Control + +maintainers: + - Nam Tran + +description: | + The LP5812 is a 4x3 matrix RGB LED driver with I2C interface + and autonomous animation engine control. + For more product information please see the link below: + https://www.ti.com/product/LP5812#tech-docs + +properties: + compatible: + const: ti,lp5812 + + reg: + maxItems: 1 + + ti,scan-mode: + description: | + Selects the LED scan mode of the LP5812. The device supports + three modes: + - Direct-drive mode (by default if 'ti,scan-mode' is omitted) + drives up to 4 LEDs directly by internal current sinks (LED0-LED3). + - TCM-drive mode ("tcm::") drives up to 12 LEDs + (4 RGB) using 1-4 scan multiplexing. The specifies the number + of scans (1-4), and defines the scan order of the outpu= ts. + - Mix-drive mode ("mix:::") combines + direct-drive and TCM-drive outputs. The specifies the number + of scans, selects the direct-drive outputs, and + defines the scan order. + $ref: /schemas/types.yaml#/definitions/string + pattern: '^(tcm|mix):[1-4](:[0-3]){1,4}$' + + vcc-supply: + description: Regulator providing power to the 'VCC' pin. + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[0-3]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + minimum: 0 + maximum: 3 + + required: + - reg + + "^multi-led@[4-7]$": + type: object + $ref: leds-class-multicolor.yaml# + unevaluatedProperties: false + + properties: + reg: + minimum: 4 + maximum: 7 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^led@[4-9a-f]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + minimum: 4 + maximum: 15 + + required: + - reg + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + led-controller@1b { + #address-cells =3D <1>; + #size-cells =3D <0>; + compatible =3D "ti,lp5812"; + reg =3D <0x1b>; + ti,scan-mode =3D "tcm:4:0:1:2:3"; + vcc-supply =3D <&vdd_3v3_reg>; + + led@0 { + reg =3D <0x0>; + label =3D "LED0"; + led-max-microamp =3D <25500>; + }; + + led@1 { + reg =3D <0x1>; + label =3D "LED1"; + led-max-microamp =3D <25500>; + }; + + led@2 { + reg =3D <0x2>; + label =3D "LED2"; + led-max-microamp =3D <25500>; + }; + + led@3 { + reg =3D <0x3>; + label =3D "LED3"; + led-max-microamp =3D <25500>; + }; + + multi-led@4 { + #address-cells =3D <1>; + #size-cells =3D <0>; + reg =3D <0x4>; + color =3D ; + label =3D "LED_A"; + + led@4 { + reg =3D <0x4>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@5 { + reg =3D <0x5>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@6 { + reg =3D <0x6>; + color =3D ; + led-max-microamp =3D <25500>; + }; + }; + + multi-led@5 { + #address-cells =3D <1>; + #size-cells =3D <0>; + reg =3D <0x5>; + color =3D ; + label =3D "LED_B"; + + led@7 { + reg =3D <0x7>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@8 { + reg =3D <0x8>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@9 { + reg =3D <0x9>; + color =3D ; + led-max-microamp =3D <25500>; + }; + }; + + multi-led@6 { + #address-cells =3D <1>; + #size-cells =3D <0>; + reg =3D <0x6>; + color =3D ; + label =3D "LED_C"; + + led@a { + reg =3D <0xa>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@b { + reg =3D <0xb>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@c { + reg =3D <0xc>; + color =3D ; + led-max-microamp =3D <25500>; + }; + }; + + multi-led@7 { + #address-cells =3D <1>; + #size-cells =3D <0>; + reg =3D <0x7>; + color =3D ; + label =3D "LED_D"; + + led@d { + reg =3D <0xd>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@e { + reg =3D <0xe>; + color =3D ; + led-max-microamp =3D <25500>; + }; + + led@f { + reg =3D <0xf>; + color =3D ; + led-max-microamp =3D <25500>; + }; + }; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 5b11839cba9d..e9f5325e841a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25836,6 +25836,12 @@ S: Supported F: Documentation/devicetree/bindings/iio/dac/ti,dac7612.yaml F: drivers/iio/dac/ti-dac7612.c =20 +TEXAS INSTRUMENTS' LP5812 RGB LED DRIVER +M: Nam Tran +L: linux-leds@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/leds/ti,lp5812.yaml + TEXAS INSTRUMENTS' LB8864 LED BACKLIGHT DRIVER M: Alexander Sverdlin L: linux-leds@vger.kernel.org --=20 2.25.1 From nobody Sat Feb 7 17:55:50 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C518F21CC43 for ; Sun, 21 Dec 2025 04:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766290841; cv=none; b=ZBqP/TZtlk6/e6s5MSBATgkcXPS9tOGVijMX12+XtiQr/MzZU0BP1CgKvfPtyD6TBiVHA6WA5SH03iTnnn64DIaeztsafUuedMIp3KDIT50tZ8jP7oXnoepb4ee3afHJoRJMWMjpEyPC0aV951tx0RC02BVXGet9pYeNw6dhpYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766290841; c=relaxed/simple; bh=9AM9S1kpvvpxkFAPnG8XPXP1qvcQzy+sQTYnnfUkxRQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=L7oBK/hvEjh4VohD95JYRI8WjPKJqpi3oQ9ZIJOm7w2BeGN1xIalRVJXvkVTbn9XK9HvR7dos/jOSrp3tGqvVG7DhOi0tVNfb1nrLLj05TGDwNQonrzxSX92v1TzLJAc6n5Q4iKWkfP6wbFahxl68w0jN5OtvWg/JGj93ZfzifU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CvlNElGv; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CvlNElGv" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2a0d5c365ceso37476585ad.3 for ; Sat, 20 Dec 2025 20:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766290836; x=1766895636; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aDzvfbCjfafRCDhMcLuBf0mWHS7prKGZU+2XN0BOi/o=; b=CvlNElGv6+uKxNwLq7nbLbbcYhmjlaHGoVyYFDunbEyo89PnFwybhRp98ueqBhZ4gV tK5Su0OX3VpD45uYiSDjA+diFFRbEzQEDupGNcWh6Gxt9lDuamwsw+Me5ldepLrCqcq2 hSN57D1Ny2AFYT1SNX8PT5HChBh0ty7z3XApoTcRKjMgou8PNl13PJjXwp/GJYKkKyan my705jLfIbE7Pp18Zc45LTv1h4aypeJXC9J1irdETtQXot1MMjjNHyG59boC/PHPtGHA J9UXqdNWMAiESVpaa7cxqirKF3y3yH0NMh26uD5LeN0VpBF3VJV/gVzvktPZN0wH1XHI 4qmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766290836; x=1766895636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aDzvfbCjfafRCDhMcLuBf0mWHS7prKGZU+2XN0BOi/o=; b=agtzxIPWK5YXz2RQhY/Zk+kiabJm8ZiTZmLFMcQyguOQWPaDamSVkQaX6vYS+NojrP 1d2ofsTv/oe1TI2C1n1gWpGmVpSSCAS3bio6ki/jm6uOa3xqs41ppTLRoHxWF4zrvuhd MNfN02fgPun38+yfVbLKQ7DvaKibxrEn8DLIupnse6GJHhj8A+Axf18AyEOvfTcyPd9k vkvbInzvZyOraUzFCnh1EFwNIYCtIao0aofPxzTO699mGBegqIcoTElqcDEaBboi2lsv dvCwMAGECiRw2gVaHo5+8/2NT7a8+MzbwjxxSdXHBB36iNMpX1FmxyRvfbU/KQlzs5kj XH7w== X-Forwarded-Encrypted: i=1; AJvYcCUjHQDBgxMRBfqLMkhCIBXgTN1D4aSSVHxeyyWP+OXyM82ev661aV/TLIE6+oZO3HE2jpHW3QVgrNtQ7Qw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw46G0pYSCOQRJpn4iljypjadR/gd5xxqzdTHzZScu+UqiajnaX hL6MAIRbmbyAiMbU5U+u4VlpweFj8vuVmelAGfzE+4mfxn7j4Xto8c4W X-Gm-Gg: AY/fxX7FPRxqz32+SbDXna1TcBdzJLRGmUQHAGHvXPfkItpv+yMZv6OxKqj9kfQPzaW CnHCH+AZ13XmrmhF73+Di/FmA+33h67/zoDHvEExUqSlS8glpE3R9IFwo700yYt3RnbtvDQOhyw 5aXD9gDiinrPSoUq4LwQeHQKc8nbqkGyRcw+abIXZ8yLmqr/3dU21KbS//SPiGH9xwGpuOwHfku o7CDHbivH7QZLFYm9f5pBrGKieE8RSwInOFLFWgOzMqHvhviZ8U3aHNz1NM2soqdO2c1gT7qa/X WcpHv2MNN88pesBNyUMe84Guu6541jCSNZv0/HVd1M/qbjjfJBxDeRVjw+nqQYWxDJFN4mZ7/U7 vcQmiTbwzDpSPqh7rSFseAn/kufjRAWPqRpBltppc/MIc+0xDheIeeWrZNKw3QfDbj31o8L0MoR BRpEMDe6Ahcn3UWk2k/dBqWtg= X-Google-Smtp-Source: AGHT+IFOCozT9ez7gtNAQlxFyv2Zvpc3v8MbdLCMHTJfK9YGQWsDVpx3A1hLDZ2g6MLJSEt8fUUzSA== X-Received: by 2002:a17:902:ce82:b0:2a0:f469:1f56 with SMTP id d9443c01a7336-2a2f272b393mr81559585ad.31.1766290835714; Sat, 20 Dec 2025 20:20:35 -0800 (PST) Received: from localhost.localdomain ([14.255.43.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3d4cb90sm62319245ad.51.2025.12.20.20.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Dec 2025 20:20:35 -0800 (PST) From: Nam Tran To: lee@kernel.org Cc: pavel@kernel.org, gregkh@linuxfoundation.org, rdunlap@infradead.org, christophe.jaillet@wanadoo.fr, krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org, corbet@lwn.net, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, Nam Tran Subject: [PATCH v20 2/3] leds: add basic support for TI/National Semiconductor LP5812 LED Driver Date: Sun, 21 Dec 2025 11:19:49 +0700 Message-Id: <20251221041950.4631-3-trannamatk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251221041950.4631-1-trannamatk@gmail.com> References: <20251221041950.4631-1-trannamatk@gmail.com> 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 The LP5812 is a 4x3 matrix RGB LED driver with an autonomous animation engine and time-cross-multiplexing (TCM) support for up to 12 LEDs or 4 RGB LEDs. Each LED can be configured through the related registers to realize vivid and fancy lighting effects. This patch adds minimal driver support for the LP5812, implementing only the essential functionality: I2C communication with the device, LED registration, brightness control in manual mode, and basic sysfs interfaces for LED configuration and fault monitoring. Signed-off-by: Nam Tran --- MAINTAINERS | 4 + drivers/leds/rgb/Kconfig | 13 + drivers/leds/rgb/Makefile | 1 + drivers/leds/rgb/leds-lp5812.c | 642 +++++++++++++++++++++++++++++++++ drivers/leds/rgb/leds-lp5812.h | 172 +++++++++ 5 files changed, 832 insertions(+) create mode 100644 drivers/leds/rgb/leds-lp5812.c create mode 100644 drivers/leds/rgb/leds-lp5812.h diff --git a/MAINTAINERS b/MAINTAINERS index e9f5325e841a..8d840b34c924 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25841,6 +25841,10 @@ M: Nam Tran L: linux-leds@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/leds/ti,lp5812.yaml +F: drivers/leds/rgb/Kconfig +F: drivers/leds/rgb/Makefile +F: drivers/leds/rgb/leds-lp5812.c +F: drivers/leds/rgb/leds-lp5812.h =20 TEXAS INSTRUMENTS' LB8864 LED BACKLIGHT DRIVER M: Alexander Sverdlin diff --git a/drivers/leds/rgb/Kconfig b/drivers/leds/rgb/Kconfig index 222d943d826a..28ef4c487367 100644 --- a/drivers/leds/rgb/Kconfig +++ b/drivers/leds/rgb/Kconfig @@ -26,6 +26,19 @@ config LEDS_KTD202X To compile this driver as a module, choose M here: the module will be called leds-ktd202x. =20 +config LEDS_LP5812 + tristate "LED support for Texas Instruments LP5812" + depends on I2C + help + If you say Y here you get support for TI LP5812 LED driver. + The LP5812 is a 4x3 matrix RGB LED driver with autonomous + animation engine control. + + To compile this driver as a module, choose M here: the + module will be called leds-lp5812. + + If unsure, say N. + config LEDS_NCP5623 tristate "LED support for NCP5623" depends on I2C diff --git a/drivers/leds/rgb/Makefile b/drivers/leds/rgb/Makefile index a501fd27f179..be45991f63f5 100644 --- a/drivers/leds/rgb/Makefile +++ b/drivers/leds/rgb/Makefile @@ -2,6 +2,7 @@ =20 obj-$(CONFIG_LEDS_GROUP_MULTICOLOR) +=3D leds-group-multicolor.o obj-$(CONFIG_LEDS_KTD202X) +=3D leds-ktd202x.o +obj-$(CONFIG_LEDS_LP5812) +=3D leds-lp5812.o obj-$(CONFIG_LEDS_NCP5623) +=3D leds-ncp5623.o obj-$(CONFIG_LEDS_PWM_MULTICOLOR) +=3D leds-pwm-multicolor.o obj-$(CONFIG_LEDS_QCOM_LPG) +=3D leds-qcom-lpg.o diff --git a/drivers/leds/rgb/leds-lp5812.c b/drivers/leds/rgb/leds-lp5812.c new file mode 100644 index 000000000000..ce6d703641e8 --- /dev/null +++ b/drivers/leds/rgb/leds-lp5812.c @@ -0,0 +1,642 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * LP5812 LED driver + * + * Copyright (C) 2025 Texas Instruments + * + * Author: Jared Zhou + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "leds-lp5812.h" + +static const struct lp5812_mode_mapping chip_mode_map[] =3D { + {"direct_mode", 0, 0, 0, 0, 0, 0}, + {"tcm:1:0", 1, 0, 0, 0, 0, 0}, + {"tcm:1:1", 1, 1, 0, 0, 0, 0}, + {"tcm:1:2", 1, 2, 0, 0, 0, 0}, + {"tcm:1:3", 1, 3, 0, 0, 0, 0}, + {"tcm:2:0:1", 2, 0, 1, 0, 0, 0}, + {"tcm:2:0:2", 2, 0, 2, 0, 0, 0}, + {"tcm:2:0:3", 2, 0, 3, 0, 0, 0}, + {"tcm:2:1:2", 2, 1, 2, 0, 0, 0}, + {"tcm:2:1:3", 2, 1, 3, 0, 0, 0}, + {"tcm:2:2:3", 2, 2, 3, 0, 0, 0}, + {"tcm:3:0:1:2", 3, 0, 1, 2, 0, 0}, + {"tcm:3:0:1:3", 3, 0, 1, 3, 0, 0}, + {"tcm:3:0:2:3", 3, 0, 2, 3, 0, 0}, + {"tcm:4:0:1:2:3", 4, 0, 1, 2, 3, 0}, + {"mix:1:0:1", 5, 1, 0, 0, 0, 0}, + {"mix:1:0:2", 5, 2, 0, 0, 0, 0}, + {"mix:1:0:3", 5, 3, 0, 0, 0, 0}, + {"mix:1:1:0", 5, 0, 0, 0, 0, 1}, + {"mix:1:1:2", 5, 2, 0, 0, 0, 1}, + {"mix:1:1:3", 5, 3, 0, 0, 0, 1}, + {"mix:1:2:0", 5, 0, 0, 0, 0, 2}, + {"mix:1:2:1", 5, 1, 0, 0, 0, 2}, + {"mix:1:2:3", 5, 3, 0, 0, 0, 2}, + {"mix:1:3:0", 5, 0, 0, 0, 0, 3}, + {"mix:1:3:1", 5, 1, 0, 0, 0, 3}, + {"mix:1:3:2", 5, 2, 0, 0, 0, 3}, + {"mix:2:0:1:2", 6, 1, 2, 0, 0, 0}, + {"mix:2:0:1:3", 6, 1, 3, 0, 0, 0}, + {"mix:2:0:2:3", 6, 2, 3, 0, 0, 0}, + {"mix:2:1:0:2", 6, 0, 2, 0, 0, 1}, + {"mix:2:1:0:3", 6, 0, 3, 0, 0, 1}, + {"mix:2:1:2:3", 6, 2, 3, 0, 0, 1}, + {"mix:2:2:0:1", 6, 0, 1, 0, 0, 2}, + {"mix:2:2:0:3", 6, 0, 3, 0, 0, 2}, + {"mix:2:2:1:3", 6, 1, 3, 0, 0, 2}, + {"mix:2:3:0:1", 6, 0, 1, 0, 0, 3}, + {"mix:2:3:0:2", 6, 0, 2, 0, 0, 3}, + {"mix:2:3:1:2", 6, 1, 2, 0, 0, 3}, + {"mix:3:0:1:2:3", 7, 1, 2, 3, 0, 0}, + {"mix:3:1:0:2:3", 7, 0, 2, 3, 0, 1}, + {"mix:3:2:0:1:3", 7, 0, 1, 3, 0, 2}, + {"mix:3:3:0:1:2", 7, 0, 1, 2, 0, 3} +}; + +static int lp5812_write(struct lp5812_chip *chip, u16 reg, u8 val) +{ + struct device *dev =3D &chip->client->dev; + struct i2c_msg msg; + u8 buf[LP5812_DATA_LENGTH]; + u8 reg_addr_bit8_9; + int ret; + + /* Extract register address bits 9 and 8 for Address Byte 1 */ + reg_addr_bit8_9 =3D (reg >> LP5812_REG_ADDR_HIGH_SHIFT) & LP5812_REG_ADDR= _BIT_8_9_MASK; + + /* Prepare payload: Address Byte 2 (bits [7:0]) and value to write */ + buf[LP5812_DATA_BYTE_0_IDX] =3D (u8)(reg & LP5812_REG_ADDR_LOW_MASK); + buf[LP5812_DATA_BYTE_1_IDX] =3D val; + + /* Construct I2C message for a write operation */ + msg.addr =3D (chip->client->addr << LP5812_CHIP_ADDR_SHIFT) | reg_addr_bi= t8_9; + msg.flags =3D 0; + msg.len =3D sizeof(buf); + msg.buf =3D buf; + + ret =3D i2c_transfer(chip->client->adapter, &msg, 1); + if (ret =3D=3D 1) + return 0; + + dev_err(dev, "I2C write error, ret=3D%d\n", ret); + return ret < 0 ? ret : -EIO; +} + +static int lp5812_read(struct lp5812_chip *chip, u16 reg, u8 *val) +{ + struct device *dev =3D &chip->client->dev; + struct i2c_msg msgs[LP5812_READ_MSG_LENGTH]; + u8 ret_val; + u8 reg_addr_bit8_9; + u8 converted_reg; + int ret; + + /* Extract register address bits 9 and 8 for Address Byte 1 */ + reg_addr_bit8_9 =3D (reg >> LP5812_REG_ADDR_HIGH_SHIFT) & LP5812_REG_ADDR= _BIT_8_9_MASK; + + /* Lower 8 bits go in Address Byte 2 */ + converted_reg =3D (u8)(reg & LP5812_REG_ADDR_LOW_MASK); + + /* Prepare I2C write message to set register address */ + msgs[LP5812_MSG_0_IDX].addr =3D + (chip->client->addr << LP5812_CHIP_ADDR_SHIFT) | reg_addr_bit8_9; + msgs[LP5812_MSG_0_IDX].flags =3D 0; + msgs[LP5812_MSG_0_IDX].len =3D 1; + msgs[LP5812_MSG_0_IDX].buf =3D &converted_reg; + + /* Prepare I2C read message to retrieve register value */ + msgs[LP5812_MSG_1_IDX].addr =3D + (chip->client->addr << LP5812_CHIP_ADDR_SHIFT) | reg_addr_bit8_9; + msgs[LP5812_MSG_1_IDX].flags =3D I2C_M_RD; + msgs[LP5812_MSG_1_IDX].len =3D 1; + msgs[LP5812_MSG_1_IDX].buf =3D &ret_val; + + ret =3D i2c_transfer(chip->client->adapter, msgs, LP5812_READ_MSG_LENGTH); + if (ret =3D=3D LP5812_READ_MSG_LENGTH) { + *val =3D ret_val; + return 0; + } + + dev_err(dev, "I2C read error, ret=3D%d\n", ret); + *val =3D 0; + return ret < 0 ? ret : -EIO; +} + +static int lp5812_read_tsd_config_status(struct lp5812_chip *chip, u8 *reg= _val) +{ + return lp5812_read(chip, LP5812_TSD_CONFIG_STATUS, reg_val); +} + +static int lp5812_update_regs_config(struct lp5812_chip *chip) +{ + u8 reg_val; + int ret; + + ret =3D lp5812_write(chip, LP5812_CMD_UPDATE, LP5812_UPDATE_CMD_VAL); + if (ret) + return ret; + + ret =3D lp5812_read_tsd_config_status(chip, ®_val); + if (ret) + return ret; + + return reg_val & LP5812_CFG_ERR_STATUS_MASK; +} + +static ssize_t parse_drive_mode(struct lp5812_chip *chip, const char *str) +{ + int i; + + chip->drive_mode.bits.mix_sel_led_0 =3D false; + chip->drive_mode.bits.mix_sel_led_1 =3D false; + chip->drive_mode.bits.mix_sel_led_2 =3D false; + chip->drive_mode.bits.mix_sel_led_3 =3D false; + + if (sysfs_streq(str, LP5812_MODE_DIRECT_NAME)) { + chip->drive_mode.bits.led_mode =3D LP5812_MODE_DIRECT_VALUE; + return 0; + } + + for (i =3D 0; i < ARRAY_SIZE(chip_mode_map); i++) { + if (!sysfs_streq(str, chip_mode_map[i].mode_name)) + continue; + + chip->drive_mode.bits.led_mode =3D chip_mode_map[i].mode; + chip->scan_order.bits.order0 =3D chip_mode_map[i].scan_order_0; + chip->scan_order.bits.order1 =3D chip_mode_map[i].scan_order_1; + chip->scan_order.bits.order2 =3D chip_mode_map[i].scan_order_2; + chip->scan_order.bits.order3 =3D chip_mode_map[i].scan_order_3; + + switch (chip_mode_map[i].selection_led) { + case LP5812_MODE_MIX_SELECT_LED_0: + chip->drive_mode.bits.mix_sel_led_0 =3D true; + break; + case LP5812_MODE_MIX_SELECT_LED_1: + chip->drive_mode.bits.mix_sel_led_1 =3D true; + break; + case LP5812_MODE_MIX_SELECT_LED_2: + chip->drive_mode.bits.mix_sel_led_2 =3D true; + break; + case LP5812_MODE_MIX_SELECT_LED_3: + chip->drive_mode.bits.mix_sel_led_3 =3D true; + break; + default: + return -EINVAL; + } + + return 0; + } + + return -EINVAL; +} + +static int lp5812_set_drive_mode_scan_order(struct lp5812_chip *chip) +{ + u8 val; + int ret; + + val =3D chip->drive_mode.val; + ret =3D lp5812_write(chip, LP5812_DEV_CONFIG1, val); + if (ret) + return ret; + + val =3D chip->scan_order.val; + ret =3D lp5812_write(chip, LP5812_DEV_CONFIG2, val); + + return ret; +} + +static int lp5812_set_led_mode(struct lp5812_chip *chip, int led_number, + enum control_mode mode) +{ + u8 reg_val; + u16 reg; + int ret; + + /* + * Select device configuration register. + * Reg3 for LED_0=E2=80=93LED_3, LED_A0=E2=80=93A2, LED_B0 + * Reg4 for LED_B1=E2=80=93B2, LED_C0=E2=80=93C2, LED_D0=E2=80=93D2 + */ + if (led_number < LP5812_NUMBER_LED_IN_REG) + reg =3D LP5812_DEV_CONFIG3; + else + reg =3D LP5812_DEV_CONFIG4; + + ret =3D lp5812_read(chip, reg, ®_val); + if (ret) + return ret; + + if (mode =3D=3D LP5812_MODE_MANUAL) + reg_val &=3D ~(LP5812_ENABLE << (led_number % LP5812_NUMBER_LED_IN_REG)); + else + reg_val |=3D (LP5812_ENABLE << (led_number % LP5812_NUMBER_LED_IN_REG)); + + ret =3D lp5812_write(chip, reg, reg_val); + if (ret) + return ret; + + ret =3D lp5812_update_regs_config(chip); + + return ret; +} + +static int lp5812_manual_dc_pwm_control(struct lp5812_chip *chip, int led_= number, + u8 val, enum dimming_type dimming_type) +{ + u16 led_base_reg; + int ret; + + if (dimming_type =3D=3D LP5812_DIMMING_ANALOG) + led_base_reg =3D LP5812_MANUAL_DC_BASE; + else + led_base_reg =3D LP5812_MANUAL_PWM_BASE; + + ret =3D lp5812_write(chip, led_base_reg + led_number, val); + + return ret; +} + +static int lp5812_multicolor_brightness(struct lp5812_led *led) +{ + struct lp5812_chip *chip =3D led->chip; + int ret, i; + + guard(mutex)(&chip->lock); + for (i =3D 0; i < led->mc_cdev.num_colors; i++) { + ret =3D lp5812_manual_dc_pwm_control(chip, led->mc_cdev.subled_info[i].c= hannel, + led->mc_cdev.subled_info[i].brightness, + LP5812_DIMMING_PWM); + if (ret) + return ret; + } + + return 0; +} + +static int lp5812_led_brightness(struct lp5812_led *led) +{ + struct lp5812_chip *chip =3D led->chip; + struct lp5812_led_config *led_cfg; + int ret; + + led_cfg =3D &chip->led_config[led->chan_nr]; + + guard(mutex)(&chip->lock); + ret =3D lp5812_manual_dc_pwm_control(chip, led_cfg->led_id[0], + led->brightness, LP5812_DIMMING_PWM); + + return ret; +} + +static int lp5812_set_brightness(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct lp5812_led *led =3D container_of(cdev, struct lp5812_led, cdev); + + led->brightness =3D (u8)brightness; + + return lp5812_led_brightness(led); +} + +static int lp5812_set_mc_brightness(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct led_classdev_mc *mc_dev =3D lcdev_to_mccdev(cdev); + struct lp5812_led *led =3D container_of(mc_dev, struct lp5812_led, mc_cde= v); + + led_mc_calc_color_components(&led->mc_cdev, brightness); + + return lp5812_multicolor_brightness(led); +} + +static int lp5812_init_led(struct lp5812_led *led, struct lp5812_chip *chi= p, int chan) +{ + struct device *dev =3D &chip->client->dev; + struct mc_subled *mc_led_info; + struct led_classdev *led_cdev; + int i, ret; + + if (chip->led_config[chan].name) { + led->cdev.name =3D chip->led_config[chan].name; + } else { + led->cdev.name =3D devm_kasprintf(dev, GFP_KERNEL, "%s:channel%d", + chip->label ? : chip->client->name, chan); + if (!led->cdev.name) + return -ENOMEM; + } + + if (!chip->led_config[chan].is_sc_led) { + mc_led_info =3D devm_kcalloc(dev, chip->led_config[chan].num_colors, + sizeof(*mc_led_info), GFP_KERNEL); + if (!mc_led_info) + return -ENOMEM; + + led_cdev =3D &led->mc_cdev.led_cdev; + led_cdev->name =3D led->cdev.name; + led_cdev->brightness_set_blocking =3D lp5812_set_mc_brightness; + led->mc_cdev.num_colors =3D chip->led_config[chan].num_colors; + + for (i =3D 0; i < led->mc_cdev.num_colors; i++) { + mc_led_info[i].color_index =3D chip->led_config[chan].color_id[i]; + mc_led_info[i].channel =3D chip->led_config[chan].led_id[i]; + } + + led->mc_cdev.subled_info =3D mc_led_info; + } else { + led->cdev.brightness_set_blocking =3D lp5812_set_brightness; + } + + led->chan_nr =3D chan; + + if (chip->led_config[chan].is_sc_led) { + ret =3D devm_led_classdev_register(dev, &led->cdev); + if (ret =3D=3D 0) + led->cdev.dev->platform_data =3D led; + } else { + ret =3D devm_led_classdev_multicolor_register(dev, &led->mc_cdev); + if (ret =3D=3D 0) + led->mc_cdev.led_cdev.dev->platform_data =3D led; + } + + return ret; +} + +static int lp5812_register_leds(struct lp5812_led *leds, struct lp5812_chi= p *chip) +{ + struct lp5812_led *led; + int num_channels =3D chip->num_channels; + u8 reg_val; + u16 reg; + int ret, i, j; + + for (i =3D 0; i < num_channels; i++) { + led =3D &leds[i]; + ret =3D lp5812_init_led(led, chip, i); + if (ret) + goto err_init_led; + + led->chip =3D chip; + + for (j =3D 0; j < chip->led_config[i].num_colors; j++) { + ret =3D lp5812_write(chip, + LP5812_AUTO_DC_BASE + chip->led_config[i].led_id[j], + chip->led_config[i].max_current[j]); + if (ret) + goto err_init_led; + + ret =3D lp5812_manual_dc_pwm_control(chip, chip->led_config[i].led_id[j= ], + chip->led_config[i].max_current[j], + LP5812_DIMMING_ANALOG); + if (ret) + goto err_init_led; + + ret =3D lp5812_set_led_mode(chip, chip->led_config[i].led_id[j], + LP5812_MODE_MANUAL); + if (ret) + goto err_init_led; + + reg =3D (chip->led_config[i].led_id[j] < LP5812_NUMBER_LED_IN_REG) ? + LP5812_LED_EN_1 : LP5812_LED_EN_2; + + ret =3D lp5812_read(chip, reg, ®_val); + if (ret) + goto err_init_led; + + reg_val |=3D (LP5812_ENABLE << (chip->led_config[i].led_id[j] % + LP5812_NUMBER_LED_IN_REG)); + + ret =3D lp5812_write(chip, reg, reg_val); + if (ret) + goto err_init_led; + } + } + + return 0; + +err_init_led: + return ret; +} + +static int lp5812_init_device(struct lp5812_chip *chip) +{ + int ret; + + usleep_range(LP5812_WAIT_DEVICE_STABLE_MIN, LP5812_WAIT_DEVICE_STABLE_MAX= ); + + ret =3D lp5812_write(chip, LP5812_REG_ENABLE, LP5812_ENABLE); + if (ret) { + dev_err(&chip->client->dev, "failed to enable LP5812 device\n"); + return ret; + } + + ret =3D lp5812_write(chip, LP5812_DEV_CONFIG12, LP5812_LSD_LOD_START_UP); + if (ret) { + dev_err(&chip->client->dev, "failed to configure device safety threshold= s\n"); + return ret; + } + + ret =3D parse_drive_mode(chip, chip->scan_mode); + if (ret) + return ret; + + ret =3D lp5812_set_drive_mode_scan_order(chip); + if (ret) + return ret; + + ret =3D lp5812_update_regs_config(chip); + if (ret) { + dev_err(&chip->client->dev, "failed to apply configuration updates\n"); + return ret; + } + + return 0; +} + +static void lp5812_deinit_device(struct lp5812_chip *chip) +{ + lp5812_write(chip, LP5812_LED_EN_1, LP5812_DISABLE); + lp5812_write(chip, LP5812_LED_EN_2, LP5812_DISABLE); + lp5812_write(chip, LP5812_REG_ENABLE, LP5812_DISABLE); +} + +static int lp5812_parse_led_channel(struct device_node *np, + struct lp5812_led_config *cfg, + int color_number) +{ + int color_id, reg, ret; + u32 max_cur; + + ret =3D of_property_read_u32(np, "reg", ®); + if (ret) + return ret; + + cfg->led_id[color_number] =3D reg; + + ret =3D of_property_read_u32(np, "led-max-microamp", &max_cur); + if (ret) + max_cur =3D 0; + /* Convert microamps to driver units */ + cfg->max_current[color_number] =3D max_cur / 100; + + ret =3D of_property_read_u32(np, "color", &color_id); + if (ret) + color_id =3D 0; + cfg->color_id[color_number] =3D color_id; + + return 0; +} + +static int lp5812_parse_led(struct device_node *np, + struct lp5812_led_config *cfg, + int led_index) +{ + int num_colors, ret; + + of_property_read_string(np, "label", &cfg[led_index].name); + + ret =3D of_property_read_u32(np, "reg", &cfg[led_index].chan_nr); + if (ret) + return ret; + + num_colors =3D 0; + for_each_available_child_of_node_scoped(np, child) { + ret =3D lp5812_parse_led_channel(child, &cfg[led_index], num_colors); + if (ret) + return ret; + + num_colors++; + } + + if (num_colors =3D=3D 0) { + ret =3D lp5812_parse_led_channel(np, &cfg[led_index], 0); + if (ret) + return ret; + + num_colors =3D 1; + cfg[led_index].is_sc_led =3D true; + } else { + cfg[led_index].is_sc_led =3D false; + } + + cfg[led_index].num_colors =3D num_colors; + + return 0; +} + +static int lp5812_of_probe(struct device *dev, + struct device_node *np, + struct lp5812_chip *chip) +{ + struct lp5812_led_config *cfg; + int num_channels, i =3D 0, ret; + + num_channels =3D of_get_available_child_count(np); + if (num_channels =3D=3D 0) { + dev_err(dev, "no LED channels\n"); + return -EINVAL; + } + + cfg =3D devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL); + if (!cfg) + return -ENOMEM; + + chip->led_config =3D &cfg[0]; + chip->num_channels =3D num_channels; + + for_each_available_child_of_node_scoped(np, child) { + ret =3D lp5812_parse_led(child, cfg, i); + if (ret) + return -EINVAL; + i++; + } + + ret =3D of_property_read_string(np, "ti,scan-mode", &chip->scan_mode); + if (ret) + chip->scan_mode =3D LP5812_MODE_DIRECT_NAME; + + of_property_read_string(np, "label", &chip->label); + + return 0; +} + +static int lp5812_probe(struct i2c_client *client) +{ + struct lp5812_chip *chip; + struct device_node *np =3D dev_of_node(&client->dev); + struct lp5812_led *leds; + int ret; + + if (!np) + return -EINVAL; + + chip =3D devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + + ret =3D lp5812_of_probe(&client->dev, np, chip); + if (ret) + return ret; + + leds =3D devm_kcalloc(&client->dev, chip->num_channels, sizeof(*leds), GF= P_KERNEL); + if (!leds) + return -ENOMEM; + + chip->client =3D client; + mutex_init(&chip->lock); + i2c_set_clientdata(client, chip); + + ret =3D lp5812_init_device(chip); + if (ret) + return ret; + + ret =3D lp5812_register_leds(leds, chip); + if (ret) + goto err_out; + + return 0; + +err_out: + lp5812_deinit_device(chip); + return ret; +} + +static void lp5812_remove(struct i2c_client *client) +{ + struct lp5812_chip *chip =3D i2c_get_clientdata(client); + + lp5812_deinit_device(chip); +} + +static const struct of_device_id of_lp5812_match[] =3D { + { .compatible =3D "ti,lp5812" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, of_lp5812_match); + +static struct i2c_driver lp5812_driver =3D { + .driver =3D { + .name =3D "lp5812", + .of_match_table =3D of_lp5812_match, + }, + .probe =3D lp5812_probe, + .remove =3D lp5812_remove, +}; +module_i2c_driver(lp5812_driver); + +MODULE_DESCRIPTION("Texas Instruments LP5812 LED Driver"); +MODULE_AUTHOR("Jared Zhou "); +MODULE_LICENSE("GPL"); diff --git a/drivers/leds/rgb/leds-lp5812.h b/drivers/leds/rgb/leds-lp5812.h new file mode 100644 index 000000000000..d8728ecd90b3 --- /dev/null +++ b/drivers/leds/rgb/leds-lp5812.h @@ -0,0 +1,172 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * LP5812 Driver Header + * + * Copyright (C) 2025 Texas Instruments + * + * Author: Jared Zhou + */ + +#ifndef _LP5812_H_ +#define _LP5812_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define LP5812_REG_ENABLE 0x0000 +#define LP5812_REG_RESET 0x0023 +#define LP5812_DEV_CONFIG0 0x0001 +#define LP5812_DEV_CONFIG1 0x0002 +#define LP5812_DEV_CONFIG2 0x0003 +#define LP5812_DEV_CONFIG3 0x0004 +#define LP5812_DEV_CONFIG4 0x0005 +#define LP5812_DEV_CONFIG5 0x0006 +#define LP5812_DEV_CONFIG6 0x0007 +#define LP5812_DEV_CONFIG7 0x0008 +#define LP5812_DEV_CONFIG8 0x0009 +#define LP5812_DEV_CONFIG9 0x000A +#define LP5812_DEV_CONFIG10 0x000B +#define LP5812_DEV_CONFIG11 0x000c +#define LP5812_DEV_CONFIG12 0x000D +#define LP5812_CMD_UPDATE 0x0010 +#define LP5812_LED_EN_1 0x0020 +#define LP5812_LED_EN_2 0x0021 +#define LP5812_FAULT_CLEAR 0x0022 +#define LP5812_MANUAL_DC_BASE 0x0030 +#define LP5812_AUTO_DC_BASE 0x0050 +#define LP5812_MANUAL_PWM_BASE 0x0040 + +#define LP5812_TSD_CONFIG_STATUS 0x0300 +#define LP5812_LOD_STATUS 0x0301 +#define LP5812_LSD_STATUS 0x0303 + +#define LP5812_ENABLE 0x01 +#define LP5812_DISABLE 0x00 +#define FAULT_CLEAR_ALL 0x07 +#define TSD_CLEAR_VAL 0x04 +#define LSD_CLEAR_VAL 0x02 +#define LOD_CLEAR_VAL 0x01 +#define LP5812_RESET 0x66 +#define LP5812_DEV_CONFIG12_DEFAULT 0x08 + +#define LP5812_UPDATE_CMD_VAL 0x55 +#define LP5812_REG_ADDR_HIGH_SHIFT 8 +#define LP5812_REG_ADDR_BIT_8_9_MASK 0x03 +#define LP5812_REG_ADDR_LOW_MASK 0xFF +#define LP5812_CHIP_ADDR_SHIFT 2 +#define LP5812_DATA_LENGTH 2 +#define LP5812_DATA_BYTE_0_IDX 0 +#define LP5812_DATA_BYTE_1_IDX 1 + +#define LP5812_READ_MSG_LENGTH 2 +#define LP5812_MSG_0_IDX 0 +#define LP5812_MSG_1_IDX 1 +#define LP5812_CFG_ERR_STATUS_MASK 0x01 +#define LP5812_CFG_TSD_STATUS_SHIFT 1 +#define LP5812_CFG_TSD_STATUS_MASK 0x01 + +#define LP5812_FAULT_CLEAR_LOD 0 +#define LP5812_FAULT_CLEAR_LSD 1 +#define LP5812_FAULT_CLEAR_TSD 2 +#define LP5812_FAULT_CLEAR_ALL 3 +#define LP5812_NUMBER_LED_IN_REG 8 + +#define LP5812_WAIT_DEVICE_STABLE_MIN 1000 +#define LP5812_WAIT_DEVICE_STABLE_MAX 1100 + +#define LP5812_LSD_LOD_START_UP 0x0B +#define LP5812_MODE_NAME_MAX_LEN 20 +#define LP5812_MODE_DIRECT_NAME "direct_mode" +#define LP5812_MODE_DIRECT_VALUE 0 +#define LP5812_MODE_MIX_SELECT_LED_0 0 +#define LP5812_MODE_MIX_SELECT_LED_1 1 +#define LP5812_MODE_MIX_SELECT_LED_2 2 +#define LP5812_MODE_MIX_SELECT_LED_3 3 + +enum control_mode { + LP5812_MODE_MANUAL =3D 0, + LP5812_MODE_AUTONOMOUS +}; + +enum dimming_type { + LP5812_DIMMING_ANALOG, + LP5812_DIMMING_PWM +}; + +union lp5812_scan_order { + struct { + u8 order0:2; + u8 order1:2; + u8 order2:2; + u8 order3:2; + } bits; + u8 val; +}; + +union lp5812_drive_mode { + struct { + u8 mix_sel_led_0:1; + u8 mix_sel_led_1:1; + u8 mix_sel_led_2:1; + u8 mix_sel_led_3:1; + u8 led_mode:3; + u8 pwm_fre:1; + } bits; + u8 val; +}; + +struct lp5812_reg { + u16 addr; + union { + u8 val; + u8 mask; + u8 shift; + }; +}; + +struct lp5812_mode_mapping { + char mode_name[LP5812_MODE_NAME_MAX_LEN]; + u8 mode; + u8 scan_order_0; + u8 scan_order_1; + u8 scan_order_2; + u8 scan_order_3; + u8 selection_led; +}; + +struct lp5812_led_config { + bool is_sc_led; + const char *name; + u8 color_id[LED_COLOR_ID_MAX]; + u32 max_current[LED_COLOR_ID_MAX]; + int chan_nr; + int num_colors; + int led_id[LED_COLOR_ID_MAX]; +}; + +struct lp5812_chip { + u8 num_channels; + struct i2c_client *client; + struct mutex lock; /* Protects register access */ + struct lp5812_led_config *led_config; + const char *label; + const char *scan_mode; + union lp5812_scan_order scan_order; + union lp5812_drive_mode drive_mode; +}; + +struct lp5812_led { + u8 brightness; + int chan_nr; + struct led_classdev cdev; + struct led_classdev_mc mc_cdev; + struct lp5812_chip *chip; +}; + +#endif /*_LP5812_H_*/ --=20 2.25.1 From nobody Sat Feb 7 17:55:50 2026 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6636A221F1C for ; Sun, 21 Dec 2025 04:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766290846; cv=none; b=aW9mRTjtq+1kTMNYhIp8dH7M1chRwh9JkVGA2SGbbrAIjM13pTV5pLVuv7N8pks3d2Djz6bnZ+vwhkv2EEuts4tIbhhjQmZEu2cTHHF/jcUQtl1cfot7tdexhvUYcOPhb6r74NJq5u7ObXAz6mffe3A5x00sTW20yUo9aw19uJQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766290846; c=relaxed/simple; bh=p32qd1CMtpZrvOqiOyNxVvmMRWtTmW3d9z9hTfsYpGw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ta6bC/lsA5qfb4G3cx0VmeYCa2qHhI/VbBA1dOV5Uxyi+LuR8sB49zC0FFd0XOO4LUq6CBQUiGv1VZHC/J8fAPLonVM00kqXTenwP24JcGgkfxaJwbD3Fzl1AHyO8x4buJnYD7IL0+R39fb6cscBl3rkYYlf/YWFwjCvCT65mg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eQhNzP2h; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eQhNzP2h" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-2a0833b5aeeso40796945ad.1 for ; Sat, 20 Dec 2025 20:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766290842; x=1766895642; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XnP7OKw91qUHBafMZ5I1kAG02nR+3IKvTt8SsYgVCHw=; b=eQhNzP2hyJPrrXzQHti/TlHxYQ7rh820FC1uSKeiaxBMTqW84YClOkDOgmygSLcyJ4 SD7T+3YXTNzDJwuQBzzlnYy8OL4jZY2C3Bd6dYXK2n2fz+GlvKzy+3xFnnGZhuthLJ0O 7mFdd67OeJL9rCg1Ovina79UX447bw20MpLPeOChQ5DktvBIcGRC10lCKOOhLIYZtSPc xEo6dyOsKpOR12doH04Z/OIdjjwvfv8glw1cidp4j//+3R1egb/W5ZJR9wENagxRKmf+ FgMyE/3ErvPTbrLXLncnHzR/cMN+DW6Sp4Hu8CsA+CXpHz2aaDel++dpaRcTT+mbuz5e WJzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766290842; x=1766895642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XnP7OKw91qUHBafMZ5I1kAG02nR+3IKvTt8SsYgVCHw=; b=YpZx6wPvtvEH0HC4TV556Zxho1FsJtGa3JzaICW5zS0Igzjt/1QVw5TecVcvakuLkg Pehg+qbyQjwtZX2KzT1y21ZmxwdXAsJolG/8WOZvHxDQmndII6Uxu7N7idw/+KgQiXik Rl6kkg0GOl4DfQLNjux4eOF9uciegXQoa/0aim3OtZM2t9Nfu3HHy8MpTMSI6NidD2mQ P7ggELIx9wU6ccssxNSlZ7R5P4OH2y6UyY3X3LSet0ANZYxZ09dx7dXNixrH2jnIGmPa yfno4pwh5pjQmBnT3hURcFxDCQDRVQr8QFRWu0XAoDD6/xoNvjFYkjYHyEjmWzkUeGzT K+MQ== X-Forwarded-Encrypted: i=1; AJvYcCUDu0FelMnD1AfPO2RZ3NZxsQKIAFOV4PHtfcmzibNFqiKI48ilhXOspXspBmSfpHTjlsbJ85kYBcpTK8c=@vger.kernel.org X-Gm-Message-State: AOJu0YyHIp7jlQ+0/X9jX/R+z1FPVWLRRuUrUiCGrUB8jh3Z/9JRrS6M JYOyiePBjFO6VmhWkPpfF8GJxUs0+rr3EHUAtnUgZBzuxpbdVa74ItIW X-Gm-Gg: AY/fxX7jPiiTqPl0eb+l+dck2YEQr0wrFnN65vFdsFDDgYOavXbgA3O0Jovx7rEcg+o SudAB9sbYVvmtvmIUko5/rHvufnYQ5W3hqhs16DYWcVrHkUcIyZblCMPNJmz+KbEyVZvHVi1QQS 9jUjLxk6D5UYmv4J2kgYIm9MHT0dE2wNMxSuOjEKqlcvqYvctrj1jpZHuiLCrcZf61i9riQTxsS OBNPdfBcuCvtxKhhgIu3aF9+n7Ir7aXlg+JwIM+eNYEquWYa2qG5YZhLNrUmEmQK0ln4EdCX0hp o/vKGdDbVcN7sIgss6PrZht847hIK8UiSRfH74znTHTaLmgzl2nyPpb8I6Jz2gHZUkb4AUm74mA ev+LA93YOPsW816yT5negQeBhP+7Ect8u6BZ3l7yS0jcDuxyn0YDw6twappYO3cZ3IMGWwp+mKM z2WbcFA3IAF+wMRHfXAEaeoqY= X-Google-Smtp-Source: AGHT+IGmGZSCNhEhHjUIS60wSnhLvOSqRgduWOyCEsTNRSYTC/0ddkkGHZQMcpHHjFAEheFEk433nw== X-Received: by 2002:a17:903:2342:b0:2a0:e5cd:80a1 with SMTP id d9443c01a7336-2a2f2a34fa1mr71333975ad.41.1766290842511; Sat, 20 Dec 2025 20:20:42 -0800 (PST) Received: from localhost.localdomain ([14.255.43.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3d4cb90sm62319245ad.51.2025.12.20.20.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Dec 2025 20:20:42 -0800 (PST) From: Nam Tran To: lee@kernel.org Cc: pavel@kernel.org, gregkh@linuxfoundation.org, rdunlap@infradead.org, christophe.jaillet@wanadoo.fr, krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org, corbet@lwn.net, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, Nam Tran Subject: [PATCH v20 3/3] docs: leds: Document TI LP5812 LED driver Date: Sun, 21 Dec 2025 11:19:50 +0700 Message-Id: <20251221041950.4631-4-trannamatk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251221041950.4631-1-trannamatk@gmail.com> References: <20251221041950.4631-1-trannamatk@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The driver provides sysfs interfaces to control and configure the LP5812 device and its LED channels. The documetation describes the chip's capabilities, sysfs interface, and usage examples. Signed-off-by: Nam Tran --- Documentation/leds/index.rst | 1 + Documentation/leds/leds-lp5812.rst | 50 ++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 3 files changed, 52 insertions(+) create mode 100644 Documentation/leds/leds-lp5812.rst diff --git a/Documentation/leds/index.rst b/Documentation/leds/index.rst index 76fae171039c..bebf44004278 100644 --- a/Documentation/leds/index.rst +++ b/Documentation/leds/index.rst @@ -25,6 +25,7 @@ LEDs leds-lp5523 leds-lp5562 leds-lp55xx + leds-lp5812 leds-mlxcpld leds-mt6370-rgb leds-sc27xx diff --git a/Documentation/leds/leds-lp5812.rst b/Documentation/leds/leds-l= p5812.rst new file mode 100644 index 000000000000..c2a6368d5149 --- /dev/null +++ b/Documentation/leds/leds-lp5812.rst @@ -0,0 +1,50 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Kernel driver for lp5812 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +* TI/National Semiconductor LP5812 LED Driver +* Datasheet: https://www.ti.com/product/LP5812#tech-docs + +Authors: Jared Zhou + +Description +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The LP5812 is a 4x3 matrix LED driver with support for both manual and +autonomous animation control. This driver provides sysfs interfaces to +control and configure the LP5812 device and its LED channels. + +Sysfs Interface +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This driver uses the standard multicolor LED class interfaces defined +in Documentation/ABI/testing/sysfs-class-led-multicolor.rst. + +Each LP5812 LED output appears under ``/sys/class/leds/`` with its +assigned label (for example ``LED_A``). + +The following attributes are exposed: + - multi_intensity: Per-channel RGB intensity control + - brightness: Standard brightness control (0-255) + +Autonomous Control Modes +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The driver also supports autonomous control through pattern configuration +(e.g., direct, tcmscan, or mixscan modes) defined in the device tree. +When configured, the LP5812 can generate transitions and color effects +without CPU intervention. + +Refer to the device tree binding document for valid mode strings and +configuration examples. + +Example Usage +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +To control LED_A:: + # Set RGB intensity (R=3D50, G=3D50, B=3D50) + echo 50 50 50 > /sys/class/leds/LED_A/multi_intensity + # Set overall brightness to maximum + echo 255 > /sys/class/leds/LED_A/brightness diff --git a/MAINTAINERS b/MAINTAINERS index 8d840b34c924..394165660e67 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25841,6 +25841,7 @@ M: Nam Tran L: linux-leds@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/leds/ti,lp5812.yaml +F: Documentation/leds/leds-lp5812.rst F: drivers/leds/rgb/Kconfig F: drivers/leds/rgb/Makefile F: drivers/leds/rgb/leds-lp5812.c --=20 2.25.1