From nobody Mon Dec 1 22:36:58 2025 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 64C60283FEF for ; Sun, 30 Nov 2025 15:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764517216; cv=none; b=YcHXU0NQ1N/M1jN74yrwwkI6ocWZ15uoxwKNR8ivFGQZlZA7CdWJrJLbiA40NpE1CJZ7x/WfiEgGebjNBh37Y2u9nFRF8YBmiVegRoUbz7ivLPv5CbkaQOQNcQlUBa5OpXGQCwdGEcULRJ95FCGBwMUdFrZoe9zQVglssxZSF8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764517216; c=relaxed/simple; bh=zkn8kltLhz23EcttZ3N9WNmv4oYYrlz6KY+wvuCiKpM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=m7qUWd3Kf8MRDPds6Hr+SuVz5TDeAs5UGDT6Sr5mEFWbB+gmXYp0/IN5686ShxJ3/wVwrQzAFbUbX2L7Z9Lr9YhGhb7W210CbPrtX8gPJTQeQE6kbmy+8Asib4S/ESQKm4PZ+/fCCq2/YQLc3n0dNdFkgcqAKdUwKrZEbvstZWw= 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=WbAmPc6F; arc=none smtp.client-ip=209.85.214.181 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="WbAmPc6F" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-29558061c68so41308845ad.0 for ; Sun, 30 Nov 2025 07:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764517214; x=1765122014; 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=P6T+D/cptipZ1zMSMuOxtYB2gBcAx2I+UDBRGZjvt1w=; b=WbAmPc6F+waHectJNLeIHKWMRYIUTU8jz0Shmx96NKTHV8KgESClYRQpWjHfYBIbIa BNDlYlLmsQrorbSLLPAZpA5LLDVvlS/IFdeX979lgdv9zz9H6H8IwFVa8dV6bK9lXlBc tCN4HXle4sPJ30CH7FLBXRqx/lxbk/LCztqazq5O2AYLs608VroUfwST0HNpvumbQFWi 76vPUA4+ZDpEDj4Cqjndej53RAKDq4+7k+HWagF0ic1wX9sUfV5H76CnbquhNUwuc6kn lMCy1rwOLZCqwKy/GcfDZo50gtLfdEax9b3SHXbJnl1wE/mcZ7lgeYemYwthiEzkQTjD eXig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764517214; x=1765122014; 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=P6T+D/cptipZ1zMSMuOxtYB2gBcAx2I+UDBRGZjvt1w=; b=m83TKvV7wSo0NitYCnArmwp8U2kDtn7RpvWbYfjkB0MNdreWFoy6Rdi2fiw/zVp1F+ +Q13Q+4eTjJnZlFaTV3cvBLAJWzjDy8KaQA8GX3obW3hCK7EjaLauqiTSiUXsLpNCfj+ 1U2QSj0dT0ohzFldnzx/j1WtREqWuU2XwJXO4KAcZMD3ziI9BBRkoRnQrJ10pg+CUCkP pogTaTXhWHJ0K8dQuez++hEScmakRVkjkoE6CvPrQvu6DxywUX+f5XnKZQMmh0LBRGqJ vRxoXFPzwJTIuBC7wjb6yU/Cv4Ke5GtJpB/x2pwHOy3EyPKXQG9aAxnDdJhJCov4HB5J 64kA== X-Forwarded-Encrypted: i=1; AJvYcCVP8WBge6twaygSq2H14smCxXR6Hy1wfdZpE8RpHpYx5rF3N2HaKYy+0JwUzDR7TbYaGVlE73p/qaxNTNU=@vger.kernel.org X-Gm-Message-State: AOJu0YwW+/HucR0vjFGsRY1qy2p227agr7UL0F41ZayPKdTJ96SHevO1 4zzMaYeO31gOdt/QCoyCqqYW/pyq3LIwmJJgyzF6qm4RDzS3zxjuTUwP X-Gm-Gg: ASbGncvUd2o85TmGzYzq5KQLMFbXWD9e2vPltw4T4U3Ayx4bKuG7id/onjWMSWGGBfD cprBAADCI523G2DoC/Q3tgHWKMqJxXvTJ0eH9iNCZlXkVBVB4BJel2U25odLIVqycriSAck+nNB nhHuP/oe46d0I1mxY+I/f8LcZr+vaLRb0ZXbMCGI+fn+kX4ev4uw1EZ4xPUQqf50cqTjYpMdCWJ hrMs+3RH53jU3JjKkNePLqIeRZsMwSG96aooUWAuV+ooEuDlgGKYZyoLFoipJIxpVMx+lR5YNYO QbEaPTLTnBRMrohUEKCTpdzyktwovMm87tdoaT0cCJtUxLICbyeuIG2Utn8Nm6rr8QgmzgCUZMq WTY9+p+lUICKsSTJX/huw947f54b3hhRGG5/XFgHq9sMqFNE+Z6We/R8zFE0w9/mgOuaIpcFGCv JKym0C+dcYZ1vdnVi9LvL2PA== X-Google-Smtp-Source: AGHT+IHOY1KfmkmH9Lc/h5ln083JWiO/Ogem/bMvB7ufGSvT42AL5nZXRP0qWF+b0kKkAxm1iYr11g== X-Received: by 2002:a17:902:ebca:b0:295:20b8:e104 with SMTP id d9443c01a7336-29b6bfb2dbfmr355613115ad.58.1764517213656; Sun, 30 Nov 2025 07:40:13 -0800 (PST) Received: from DESKTOP-P76LG1N.lan ([42.116.199.188]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-be5e7485b1esm8640097a12.20.2025.11.30.07.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 07:40:12 -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 v19 1/3] dt-bindings: leds: add TI/National Semiconductor LP5812 LED Driver Date: Sun, 30 Nov 2025 22:39:54 +0700 Message-Id: <20251130153956.241375-2-trannamatk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251130153956.241375-1-trannamatk@gmail.com> References: <20251130153956.241375-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 e8f06145fb54..5b78d65e7625 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25449,6 +25449,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 Mon Dec 1 22:36:58 2025 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 DC9481DB375 for ; Sun, 30 Nov 2025 15:41:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764517272; cv=none; b=hDisQbtu9KeOkT60uVpnAAL5JNJfGUyTYO7IO49LyQl5MNsMeyzcOuQf6NPkCm1zc7EzQhLY+ailUw0zaArgN1NFKFWpVeKuo9F8gq4dUIUSIPpalmyDLeKttMby41MSoia5YirAb64whdgIZKUCyQ6Ni9RkV4hkFueyDb80L9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764517272; c=relaxed/simple; bh=s1YLwHPai0tUZFJ3IbVFaNXPI/XvgNlaoBoJZ+J4QLk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=EjY2R7v4Qb+T4M2Wrc2uUjTQ1vv1cg/m10QzQlhRo0Jqq+LbG4y2phRm4TRxzUwaHWFTGMrEnIcxaWgEWhsILsg53DXjK1VMsY/xjMhAmZaFPCqv+dJzELPxJQ4V6x3846G1tfYkjOSEi3JC82lrv7K96wvqHv3O7pFHKiV41Pw= 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=McXfPe+i; arc=none smtp.client-ip=209.85.216.46 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="McXfPe+i" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-34372216275so3458783a91.2 for ; Sun, 30 Nov 2025 07:41:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764517268; x=1765122068; 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=5sXJH35EshzEf45B1rAHbsqFeE4Zfw7eMVr+Rsw7OnQ=; b=McXfPe+iOKFf82EXEuQvNkoMnBIjWj5QMjOJ63/dUhxII/W8ywvmQ1Vytg6r40sBUs QwVRt2B3b3oValFNDWyni1RAxcc5Ujqxm0DHJ3VU5smzRDhxbuyscQdoDzTEKu73RHAG qTVXDLRVW5EjPftTpUK8rf1SOZZ7G937aC9Svp3goo6xsfqKfax6k8ZzgD+5I3vouCmp BhsluzKtNc4JL1QEiK0RoXAm8Yvh7euxwTpYCkOPk/TrRXJBXwkApjGMa1fErqnfyi4j ieztPS2l7hbzxbbCz2dJfhcq2MaLW1IrIBsV7Q7SrhGlSKALUSLlXBmfNt/m45Dv2vbG RWCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764517268; x=1765122068; 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=5sXJH35EshzEf45B1rAHbsqFeE4Zfw7eMVr+Rsw7OnQ=; b=l8z6SGnfyTP9AdfZhktRVH/73dxm9Y+KdGeSu/2fd+QF+YLPAXPFxQiKmmI/Ji3gXb RKPh+Z+C+nSacarhg1+9bi9eo1AknmoyzbobLKluXe3XgKf/JrbnDCIkCWvX58+Hvl4A HZDBG5qLA02nIhqh2f5YMFSorlSaChH+rlVC73OqCs/p2mPaYxTwphW/f7FMhsOJNIrS vPZwf6+KvD1hUTe8Bwhe8h2KhuF8ajck4k4xIWLZo84mGDLvikC2cMonlGjOFxqwTwfp kb17rVR4ZhLOdbOtrg05U9WO+esuSTqutBGExrPYyAXQAZwQEVAhGZJvdgfMjzlj2rui ZEmA== X-Forwarded-Encrypted: i=1; AJvYcCWhnc2OuAq8R5n/iQIcLU/soGONEYtgpt1mtWGTFc+G30/KW7hSCDPwrwrJMQ5og5bX8lOsmP0go3x/BIQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwIOHx3mHi47B3EuJHN8yxX2JOhNa9qApbAn2a2Wi+O1bMIgRHy xHtqz9h2aSysLJbVmXjFzConOZtJZd5mptVILnbHN1zlEdIGaf+eE35H X-Gm-Gg: ASbGncuAmMoaCbCXXlpPwHU9Zt0mnhyRaqXAyE3wyv2gULhztMI2iB8bbgtInoFOfTt JsNVsMZhaCjOMjletdJIYNrJCDji9zrpSTCNgndVBVz0jETG/NOVdDQa0yt1KoAfQ4w7SLLlE4l HvT4rToD91Hpmf0sXecmeceSDFjEnVQeN2ho88SenDkmZZG4d6+D8yeORsHA66HIdXjJ59DxEZb NvyeOH/VDdHMiaUk+b1pzBrtHxTfLOcP54aU4lQkoss9qj+tnnurXFJP6mMRA6PRblo52gBtMJ6 w+aQSmsA3OWLpsGXOqUoZRwZv9x/H9cQ+s705NtXCHHO32Tk+LZB+bXB+Yc/bhQCUm3+rKMkc/Z WYHTXjiwDQ2T2OsszbTMqo+CimrNT4WOS1usVdEEeQ3xhmo81Jl5zqOV7zOuPk6N9bVzn5F+ihX yGuwLOSekVYxeKhEnukne/xw== X-Google-Smtp-Source: AGHT+IGWcrFq3ZxioAVwhSUs+OHoY/75Hl6LAz1NAZ//0ndAq5Fuf5LZNPAkSsD+8jeAsKgylsRpKg== X-Received: by 2002:a17:90b:4f4c:b0:340:be40:fe0c with SMTP id 98e67ed59e1d1-34733f5c930mr30553182a91.36.1764517267948; Sun, 30 Nov 2025 07:41:07 -0800 (PST) Received: from DESKTOP-P76LG1N.lan ([42.116.199.188]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-be5e7485b1esm8640097a12.20.2025.11.30.07.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 07:41:07 -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 v19 2/3] leds: add basic support for TI/National Semiconductor LP5812 LED Driver Date: Sun, 30 Nov 2025 22:39:55 +0700 Message-Id: <20251130153956.241375-3-trannamatk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251130153956.241375-1-trannamatk@gmail.com> References: <20251130153956.241375-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 5b78d65e7625..166fb7e0ca45 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25454,6 +25454,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 Mon Dec 1 22:36:58 2025 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 C3305283FC9 for ; Sun, 30 Nov 2025 15:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764517281; cv=none; b=BfT3q2caxkGBoskgfNX+x2lA/ly5yYGtmB1VHu32BgXwjoFaNp+UBYICRLeVfwtuW1fT+x54L4gXGjUawcttjafTGg/lok67t3MvUT63zXaCBFjpg9u5DBvN3geNS/+Kggt1wWXguP/9b03o1nIuabprpbgKRL13V1ANQ/GXDYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764517281; c=relaxed/simple; bh=yknEGxi1uCob8yAl1wrjFKtlOfxHjL4MX5qcBlbJfrU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lB+r2OTs3oFmdVWVpaP2qAfgcvc5QGTethKv6x7BCgv00M2B95eqg8g8ybWpEP6KmX+BE6fqDF2Uo5KsdRrZyUwXzSSMldzb7vEiI2elmY+vK5uBlDExVrGJI7uLwzdT4YlFBsulcT61YupO2KU3ikW/+ZspbSUPCdCAV1Bx8XY= 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=YofwnR2V; arc=none smtp.client-ip=209.85.210.180 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="YofwnR2V" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7aab7623f42so3665801b3a.2 for ; Sun, 30 Nov 2025 07:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764517279; x=1765122079; 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=/jOzKc0BXX1qNRReg7a6AAzT4jmiSQSRqVhsPleD4HE=; b=YofwnR2Vu9TonAclhELCRC3jwipwXZbRq40gE0oQtaE6MXLwupvuUXHjS+p80DXVKY aHj9xhDpwqZBIRcrefyZP3F2mjM/ig5UCbOTBdd7jfpSqtHZmv2DKwri9EshcD1h1HOY 0YjGEpTD1IqAn6ZmJJ2u27btSXzFPUxfAH/HJXIBotnCSOQ3y7Sk9MLZIjI7HH9lGgpU IJRLZhSI47AAuSxVj8BYqvPEIsTLd1n3xlvcNpts1Pm8Fzof2xnEh4NuCM8fIiGu3A+d yEZ3tidnuZICKGEqYO4SozqX9dwpaYchaGWgvEOvWkvvLnLtF/OcJZolfxJDpKvacOn3 q7Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764517279; x=1765122079; 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=/jOzKc0BXX1qNRReg7a6AAzT4jmiSQSRqVhsPleD4HE=; b=QRQ6eaA3HlrZ5duUqelU/NdMSxXU7/h/g8oinPPggb0USU5GrOc/rmw/P2/HOyeGG8 S9RXtkz/Ocb8+cuqQIvi92pqcEL8Iyyw7BnNOQpLpItCEEpEzziyDYNHVSjs2pzfAccO COrTLD3+5zAyQsqq2qyb9YxhRMe9CsXgmUzMFIPoJyC37C+iigHMesHI6aZ0UW+DNfcs f6JsnE6JnQDzNp9MJGqpMLDsa41BFUhxmBnLDIqadnoqZvzcvLmvj9cVOeZgLYtjiCZr SYiuNKM2wMCTACanLfeLr0v0Ux5p9sMoOPooEE1raP2bugDHGt9GD0jnZlRnupXepmf1 bS/A== X-Forwarded-Encrypted: i=1; AJvYcCXC7KNVLVn/d+T7h84OIC2I0P2uzErIOg/wAsFiLgqedNBw20FIMwVreEefUXdasEWf8AhuEVQ6xRnvqMg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6lN5yRzBFI1r8A65L7GXRToH8cd8h2t0cTdSanZ6QgLa4MG6/ YGxevSlekKcQeRwI9r0IlHZZMLXI0RnAJUnvbHjoLmI5lNlBqoqoAF8o X-Gm-Gg: ASbGncshi/t29m6c1PfAxci1j5SiVXumZc5KUiKL6wqCw0eANhGU3SqucZ4Fpg4equ4 6gOFtJzz5GGULBuefo48JI31Q7EM4UoK7BIFo4ViU5vUBKGOgC33lJbnMDyFAha8YJIRJa8A3R4 MCqDMTchW8FxUhgd5x2EBhwB0MdWQ5H+PateTxq7sXZcoeVi1saEugRNAPQEv67/7/EA03jeYZA 4uTzyzTKrQboheEDO196yIoCP4Vcy8L59X4IGkxiZiNsbY+t2iksVVSxXW3J8vndPtG5wJ1IROV imX7lXWK1dosn9XofQ31xTPMMGU7z/m5v1tMcIBzZGE2DcM2aorGCJ+CKaDfAjFPL6eYQ+5ccmb EAbx3DxGASmFY72t1iqlYpP+UEsTZ/Yw9/t64CqXzlzt4/JdRvH4A51WZcxp92JhVP9hg3gTOcF WK9iS4+PysvkpWDb5FpkfeKQ== X-Google-Smtp-Source: AGHT+IE6IycgglZPBLNtEeo/kPKcOXO5VSy/+npfPp66iSwqU7ysTtvtelkbhYQPNj7tsQg9O5NqAw== X-Received: by 2002:a05:6a21:9983:b0:35d:d477:a7fa with SMTP id adf61e73a8af0-3614ebbb712mr34574189637.23.1764517279052; Sun, 30 Nov 2025 07:41:19 -0800 (PST) Received: from DESKTOP-P76LG1N.lan ([42.116.199.188]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-be5e7485b1esm8640097a12.20.2025.11.30.07.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 07:41:18 -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 v19 3/3] docs: leds: Document TI LP5812 LED driver Date: Sun, 30 Nov 2025 22:39:56 +0700 Message-Id: <20251130153956.241375-4-trannamatk@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20251130153956.241375-1-trannamatk@gmail.com> References: <20251130153956.241375-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 166fb7e0ca45..530c7a3ff350 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25454,6 +25454,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