From patchwork Mon May 29 16:32:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 686807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7982C77B7E for ; Mon, 29 May 2023 16:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjE2Qeq (ORCPT ); Mon, 29 May 2023 12:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjE2Qeq (ORCPT ); Mon, 29 May 2023 12:34:46 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC92AA3; Mon, 29 May 2023 09:34:43 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-30adc51b65cso2949528f8f.0; Mon, 29 May 2023 09:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685378082; x=1687970082; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+Am7a+wHpKOk5OFsVXHSbIdYxX/usU5ka2WcWHanWfY=; b=p79/40Kapo6QxF5CduIHkyC0FZ53pa9VC7iQ9G1QkBIMcPLAd584GVjVHgKK8S+5+L YB7VSHpb7dkgrRq+c5W1bUUt6Q7VTmGB5W6BrXQ94I6jAIXYjglHCnmwrIolwk3jFGUM hbyJ6F+kuXdyRDN56cvVcuM9WNnzxKzllRYnDeRcwq2tP+pSy28sgBXvOuh9bbnq5MaI opMPhNvjIyogOdjYmGknlVHqsNeh5aJZFzKSP8z2EKjfVMBBXiNwwMrXqzSv8ddCaxPQ ZnvR7IsydTdTaMOsc+aY94SKP0JOhvxkHRYXQQzRKqIXMuKDUQJ+XBcqY/kbnSVAUQ2u NcgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685378082; x=1687970082; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+Am7a+wHpKOk5OFsVXHSbIdYxX/usU5ka2WcWHanWfY=; b=ffULgZh7ieoucPlEFOxk/D41JIrlITybQ+RuDiouPyu7eteI5s8cpgyzV6uPxdUD3N pnQL0EeKpCQP7BIkbRcG9dVsMijkYhan4nwWcEf/4B03AVr7mwPyh6HtzbwFW1lmjjji k2SOB5XLeW15ClenwFbVOLisala8ZrxD+In3us9p85H+mcsCI/9+LaXL6Dg458dxqcoe y1quQDVp0vv22Pf4UJzDMgDgdI9ylz7C+n2FPtHFw+G07F1BA8d0u7yFf1hPPxuFhJ9v VUiZvSshecl35QtMKpAvdRivGjNyMiQvO93Dpf7fE4U8V9O9YMJ/Zb8asukrLkMzuMzc zRAw== X-Gm-Message-State: AC+VfDymkag8bztpOPzocWw3xdoJLgsf1chUoJcyMks0cmX51a4TR12M UKcVdKiCurXt0e4z29Kk8hU= X-Google-Smtp-Source: ACHHUZ6/WS/6kZOzkv4UzsJ3M6WllL3tEiAhFwz7zYSfQIa7/P0DEvAlQ9klHZwt0SUVHo22U1ykTQ== X-Received: by 2002:a05:6000:1009:b0:30a:f0f0:1277 with SMTP id a9-20020a056000100900b0030af0f01277mr1235670wrx.2.1685378081972; Mon, 29 May 2023 09:34:41 -0700 (PDT) Received: from localhost.localdomain (93-34-93-173.ip49.fastwebnet.it. [93.34.93.173]) by smtp.googlemail.com with ESMTPSA id h14-20020a5d6e0e000000b002ff2c39d072sm417513wrz.104.2023.05.29.09.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 09:34:41 -0700 (PDT) From: Christian Marangi To: Pavel Machek , Lee Jones , Jonathan Corbet , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , linux-leds@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [net-next PATCH v4 00/13] leds: introduce new LED hw control APIs Date: Mon, 29 May 2023 18:32:30 +0200 Message-Id: <20230529163243.9555-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Since this series is cross subsystem between LED and netdev, a stable branch was created to facilitate merging process. This is based on top of branch ib-leds-netdev-v6.5 present here [1] and rebased on top of net-next since the LED stable branch got merged. This is a continue of [2]. It was decided to take a more gradual approach to implement LEDs support for switch and phy starting with basic support and then implementing the hw control part when we have all the prereq done. This is the main part of the series, the one that actually implement the hw control API. Some history about this feature and why ======================================= This proposal is highly requested by the entire net community but the API is not strictly designed for net usage but for a more generic usage. Initial version were very flexible and designed to try to support every aspect of the LED driver with many complex function that served multiple purpose. There was an idea to have sw only and hw only LEDs and sw only and hw only LEDs. With some heads up from Andrew from the net mailing list, it was suggested to implement a more basic yet easy to implement system. These API strictly work with a designated trigger to offload their function. This may be confused with hw blink offload but LED may have an even more advanced configuration where the entire aspect of the trigger is offloaded and completely handled by the hardware. An example of this usage are PHY or switch port LEDs. Almost every of these kind of device have multiple LED attached and provide info of the current port state. Currently we lack any support of them but these device always provide a way to configure them, from basic feature like turning the LED off or no (implemented in previous series related to this feature) or even entirely driven by the hw and power on/off/blink based on some events, like tx/rx traffic, ethernet cable attached, link speed of 10mbps, 100mbps, 1000mbps or more. They can also support multiple logic like blink with traffic only if a particular link speed is attached. (an example of this is when a LED is designated to be turned on only with 100mbps link speed and configured to blink on traffic and a secondary LED of a different color is present to serve the same function but only when the link speed is 1000mbps) These case are very common for a PHY or a switch but they were never standardized so OEM support all kind of variant and configuration. Again with Andrew we compared some feature and we reached a common set of modes that are for sure present in every kind of devices. And this concludes history and why. What is present in this series ============================== This patch contain the required API to support this feature, I decided on the name of hw control to quickly describe this feature. I documented each require API in the related Documentation for leds-class so I think it might me redundant to expose them here. Feel free to tell me how to improve it if anything is not clear. On an abstract idea, this feature require this: - The trigger needs to make use of it, this is currently implemented for the netdev trigger but other trigger can be expanded if the device expose these function. An idea might be a anything that handle a storage disk and have the LED configurable to blink when there is any activity to the disk. - The LED driver needs to expose and implement these new API. Currently a LED driver supports only a trigger. The trigger should use the related helper to check if the LED can be driven hy hardware. The different modes a trigger support are exposed in the kernel include leds.h header and are used by the LED driver to understand what to do. Reviewed-by: Andrew Lunn