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 52A823009E4 for ; Tue, 30 Dec 2025 08:23:54 +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=1767083035; cv=none; b=KjwM1+oUktUixy7sNvTM/wswPGjdhXITnAqoUBRTG0GTfi4A7b0PEj/pgDELnzy1Bkn2yDIZQR6QEFJiclsP65etNRnVvOumPUFrqTHxhsEuTgSOvPzoiHOajzCsy8S0aQKUTvxD/3Wg0gfZMh+MtihaKWb7ruMWGO0OuvnN3ho= 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.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="bnJnLgB7" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2a102494058so52795165ad.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=nLaYVrvKl112fsWi3xytBqgCmQ8w+lxB5PeF/0xW3Wah6DdoZ7Snl9LKz33C/vEXyX 8wP7aGNQeFHBnahC0adNuF6CMCleL3C11HbJee0v4hBkYwewlZ4OI/2sdDShfeelF/Wq fq7pObk4hzWygwoD/4lnOVY5z32TRA7WrczEKELS+RJWM/LzhfVdEdjEkPo6Xij2+mu6 Ob01ZxKys8VLFzb6shWmakB6GdgxPFdatexbdWAiiicNKoPPsKJyk+mZn6I2qOdlIZ76 OGSRWKSCFaMSr2CZ3BcAcEDyx6Jtv7DtGzyDH1WeHzD8skrYBEEvbwERziP+ZkH3guIw L5dA== X-Gm-Message-State: AOJu0YygaUcQgBaUOo9aGxWo0yN1S6CeaxW6PCkp4l6M5AUc5OwRtWzo 27C5aAui/Q3iLrbFcCnGwW5oH3F7GU/AYtHZkTaXXOFtzG4uhHgH0gDEw8ppTg== X-Gm-Gg: AY/fxX4Wt2LLq+Q20AB9zujJExXLtB9KkcsnmxFXCMB4fVp2ZkTZcyJyRGQTzsrdMaO Vv5wA4ifdW20CmUYDXTnTFnvC6GH9RRLllrk62uL399IYza3MDzGi2AlCiJfnRir3S74gV9Z2vX yM01FMBqxEUV9hg0s9HQ4ZKz7kkSGPLd4D+AT7Qo3r1xQmOBT77U9XHlMcXy0FjOPUiygPPIygI GRPJ+XhYUO/j2kfMXP5i5wtOgaN0xfWnxm89mCTHYl6UeM2gGAKMMVVSLYqgINbxrn9SFXI8eQr /wqc7SluI9wQf25oqZh8gv2WM4Rxo9V0WMz98Sjx/hOnuYQpXmzNTRsAtPgWM+kz2Lnpf4t7syW aVviGmrELQJLn7tEEuoOsn6eBI9AIm4NyhMBGv7luPXXzcpRm7K3MatYJBFEnMa6ZWYih05goBr 1lUvf1fZdnMD2ZTHsP4DFHgVFQqWnX4cKt 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: devicetree@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