From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 52B023009EC for ; Tue, 30 Dec 2025 08:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767083035; cv=none; b=jm7aRdrvNruwtCaeEKvt7yYrow4/wf496/1E02zMJ6VvFte/3+UV+0vCVtaaeNRptcgMlRVwPH2RxyYEnp/uJlRmkL71nx0hEFLGjDEUJ1ciQo11XeoWkjz6CQk5uFOgrQ9Xi4w+TF0LupOV00P97QGstKyRAf/kiROIXdapUrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767083035; c=relaxed/simple; bh=FSU4s2p+E9acSluPQUHPxlvASLI2qpVJaKFbFRN19Rw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Srz1iGo6P1fF9aUaxJ0CkloQ6YJVAs0BR2tQKIpL5iIfFdvthfw7i3/n/h/66qDyp1tFqNjepyUofxx9BbyyGZsyZVD+bZyPplu7raQ2BZktNgHnj6u6uuYp2cMqXgOBXIMIs05sjUKehE+0tJVa/NeyzkOIBLainrJYpeb0mOs= 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=bnJnLgB7; arc=none smtp.client-ip=209.85.214.178 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="bnJnLgB7" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2a102494058so52795185ad.0 for ; Tue, 30 Dec 2025 00:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767083033; x=1767687833; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WofBUBbyzrdxS0DCtEQEyAFQaUrBpAVCVPxtgqIfim4=; b=bnJnLgB7hMfq5v4J8Tr2Q7d2MWK2+o2bk9+cLTcWwI950UD+3XXfsAcNhzXtqTWTCQ sXUjGwObL9txSws3snpuJSKcK6y3yR3lTnZb/aMqTHdL87M8FwJU+HwcXo4hNlij/CDp AoqMDc8kKdJ5/VEVhCkGq+W9p/P2xY1MHAPuWVy/L0Sf2JQCEJOrtMFZvmatsxVYmeW2 YBHoTT8+iRGBOkN1xdcXCtjcYaM8Pwut0I0OwMRYgHQFu9Lm2jwtfrbxS+I0YSbyWeyh NSotv+rjU6We+PN66FWmSolOj6Ybv/BZtxO8T4BDFgMtrD9FNd8zo2s5k6k+iisaNqst Cfxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767083033; x=1767687833; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WofBUBbyzrdxS0DCtEQEyAFQaUrBpAVCVPxtgqIfim4=; b=bGylHYP8aiHWSIPVa3990CQPDS6pMj6YqH3IBLmU3bLIKVUdTk8/v6AESOR0YBqSWb SF06AAwV6OxfTq77QvO7kIrdd1BkOWiUltwHe58ncIJgfzurAv30hbv9LBuFru249yaT hdJk+BD+6Or5/zaXGKeP4ViZJLPXG+KwOT5xQvMN5lKY0K2C7c8KL5IRAdMW2O6ARSAX ArGyHSLPY7IcToCFBJj7uH4hfKwnlXaXoU+UIgqjJrsKYgZyk309nc8b+a4X71/8puFI UN9Wt5yuRzaHCUhNb4/YgabUtZVEuPMkqMRqONicFWjTBZjB0h2NBw8MwzLvv+suePKO y9/g== X-Forwarded-Encrypted: i=1; AJvYcCUK7Yrw8yHq5qxJgMQcOBDydSpe/L0uyqhRVjeFiSFo4h2kt1IiyibG9vRvCizLRi9e+nBkRAExc8SpCSE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9ORtzuWshuIWWMUL3YAn7FPLp17TpaH8InUOv5Lp3YaUXJ9Mg ocpVchDvnBxkCFXn7jsjNfIo4BoTgrLRInofsAG4LmBvXkQswVDT7sWr X-Gm-Gg: AY/fxX62ESCuhMMWi5CAOKSDb4J57bmWoIKwJcivnTfpA68imDGOasEmKlMqxkhFlwv K9xyoggnFzBV5rLKXgVECYhRLn9ytYQRCQgpW0DgJUjhsYfrpYjDKTNpD879Zs5TS8sHF7iwYeS 6fvLrY4A1PUt+0Zn2wgIW7YwMbxaQCgqGfLJZ5UD/jSjCT1AC53Op2Bjhe27Z228V8assQcK75L vds1Hg7MxZFEab9sqYLXLMyMOoBs0iPDNxj3I0zAPqbWkK55tbRKQA79/1qVJPiC8h9N4aFyuO6 kDF7eHX1MjzjmUvKzdDCUXHmghESQQJbMSIhhbV0J+QLKwCmpgtFg30vxdBVSy9DS6VpUqqnHbU SaqVY+n7j7lFEUDekS/G0aJoLECV9zcrwdqlLGBS1KjIxfE197QSFcu25jQCQhGPXLp0I4O/LYZ LaBCWxPDEKhX+XmX6OgzVUI8e9I4KiHGc9 X-Google-Smtp-Source: AGHT+IE+zFO76dekcR+vPG/TRpO7dSesJFGRMkQGSrbquww8wHKBuINEJzUJYxLpnZou6H2+vqm+/w== X-Received: by 2002:a17:903:19c8:b0:295:50f5:c0e3 with SMTP id d9443c01a7336-2a2f0d2dbc5mr335250525ad.14.1767083033354; Tue, 30 Dec 2025 00:23:53 -0800 (PST) Received: from MRSPARKLE.localdomain ([150.228.155.85]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3d76ceesm296667165ad.91.2025.12.30.00.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 00:23:53 -0800 (PST) From: Jonathan Brophy To: lee Jones , Pavel Machek , Andriy Shevencho , Jonathan Brophy , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Radoslav Tsvetkov Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: [PATCH v5 0/7] leds: Add virtual LED group driver with priority arbitration Date: Tue, 30 Dec 2025 21:23:13 +1300 Message-ID: <20251230082336.3308403-1-professorjonny98@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jonathan Brophy This patch series introduces a new LED driver that implements virtual LED groups with priority-based arbitration for shared physical LEDs. The driver provides a multicolor LED interface while solving the problem of multiple subsystems needing to control the same physical LEDs. Key features: - Winner-takes-all priority-based arbitration - Full multicolor LED ABI compliance - Two operating modes (multicolor and standard/fixed-color) - Deterministic channel ordering by LED_COLOR_ID - Comprehensive debugfs telemetry (when CONFIG_DEBUG_FS enabled) - Optimized memory footprint (~200 bytes per LED in production builds) Use cases: - System status indicators with boot/error/update priority levels - RGB lighting with coordinated control - Multi-element LED arrays unified into single logical controls The series includes: 1. New LED function identifier for virtual LEDs 2. Device tree bindings for virtual LED class 3. Device tree bindings for virtual LED group controller 4. ABI documentation for sysfs interface 5. Comprehensive driver documentation 6. fwnode_led_get() helper for firmware-agnostic LED resolution 7. Complete driver implementation Changes since v3 commit - convert driver to pure fwnode - +Multicolor LED ABI compliance - standard multi_intensity/multi_index attributes - Winner-takes-all arbitration - deterministic control with sequence-based tie-breaking - Proper LED reference management - fwnode_led_get() + led_put() prevents leaks - 30% memory reduction - conditional debug compilation - Global ownership tracking - prevents conflicts between multiple controllers - Hierarchical locking - documented 3-tier lock order prevents deadlocks - Lock-free hardware I/O - concurrent vLED updates during physical LED access - Dual operating modes - multicolor (dynamic) and standard (fixed-color) modes - Pre-allocated arbitration buffers - zero allocations in hot path - Comprehensive power management - suspend/resume with runtime PM support Changes since v4 commit - fix yaml validation errors after feedback from maintainers from LKML Additional highlights: - Update batching for software PWM workloads - Gamma correction for perceptual brightness - Rate limiting for runaway updates - Extensive debugfs telemetry with stress testing - Deferred probe handling for late-probing LEDs - Removal race prevention with atomic flags Future enhancements planned: - dynamic led creation Chardev Interface like uleds - ubus/ dbus wrapper for linux and openwrt (out of tree) - addressable rgb support WS2812B/SK6812 - readonly leds for important kernel/ functions Testing: - Tested on ARM64 platform with GPIO and PWM LEDs - Stress tested with 10,000 iterations - Validated suspend/resume cycles - Memory leak detection passes Jonathan Brophy (7): dt-bindings: leds: Add LED_FUNCTION_VIRTUAL_STATUS identifier dt-bindings: leds: Add virtual LED class bindings dt-bindings: leds: Add virtual LED group controller bindings ABI: Add sysfs documentation for leds-group-virtualcolor leds: Add driver documentation for leds-group-virtualcolor leds: Add fwnode_led_get() for firmware-agnostic LED resolution leds: Add virtual LED group driver with priority arbitration .../sysfs-class-led-driver-virtualcolor | 168 + .../leds/leds-class-virtualcolor.yaml | 197 + .../leds/leds-group-virtualcolor.yaml | 170 + .../leds/leds-group-virtualcolor.rst | 641 ++++ drivers/leds/led-class.c | 136 +- drivers/leds/leds.h | 758 +++- drivers/leds/rgb/Kconfig | 17 + drivers/leds/rgb/Makefile | 1 + drivers/leds/rgb/leds-group-virtualcolor.c | 3360 +++++++++++++++++ include/dt-bindings/leds/common.h | 3 + 10 files changed, 5399 insertions(+), 52 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-led-driver-virtualcolor create mode 100644 Documentation/devicetree/bindings/leds/leds-class-virtualcolor.yaml create mode 100644 Documentation/devicetree/bindings/leds/leds-group-virtualcolor.yaml create mode 100644 Documentation/leds/leds-group-virtualcolor.rst create mode 100644 drivers/leds/rgb/leds-group-virtualcolor.c -- 2.43.0