Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5615883pxb; Sun, 7 Nov 2021 16:29:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCFi1amOkIYd+oXTtR9rbQfV2KxdXT5B3CnM7z3MNUrgHT+dw8BzSBy0iSLQPeDu5Tx0ZY X-Received: by 2002:a05:6402:2554:: with SMTP id l20mr32747926edb.33.1636331343478; Sun, 07 Nov 2021 16:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636331343; cv=none; d=google.com; s=arc-20160816; b=AV+EreMtjCDNUyMxYiC8hcgiiy7lUbhgcO0ip8aA9rviHn+atFNWcmOTySHbtT9AL7 Jx8skVyP93V/E/e5L6iYLpJ2Q8vQfHXY0mRncqrw7KKyl0n/U7+ngUrMw5ZKaeOky/Z+ 9omQLdrEoIJEiMTjLenZ2OTjtF4lW+7t+DCCXU23C6IKeiGQtX8nHcenMv5TU1Kp1yqq /bHNf6VmDCIRbOldO2WUMEjQ2OiuJlxCpmSueecW1Xn2f6RdEGeeUKLvpa6h3JVP61Dq w78Ia5tGNygZMxb0c41Y4jVZih7Kf5b2BlI3mNNlFmPQisQOufqciz3pVyQwCYEveVp4 0EIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QULGmrTqCLxJGFukNsnY5+P3UKYk27qIk13ZoZ0RKo4=; b=OR2IhdDVaw6FBeZszur/DsEHbzS5YUA+A3jq9s7vLldb0YTTEcT9XEpgXOlfNLkahP kFh6YIju9iUW2phxAzuXMzvbxhM9drww0accxd0HD2Pxaj0cxXqE1Vb3snXBOXpCJ3sm ucA/j05cSYuTEbjvAML87j8GOi+UgoJFFqjobILGmZjPNquaNAgfNmbta9eF5Us8Xmhw 3ljoHYyhhmBVU5oqG3T5L4LgiWlBStHzc1sy8G/RE3jA9QMYoP9RAnS+xffOj2hy6Hjo fQxWUYOAPYg14hxP28B/42IvJxPVjrPcBJ7KrNbx2x+cwkr0fzRVjTXNd/pSORZ0kLP8 hLIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m6SHADWh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si24154336edj.26.2021.11.07.16.28.39; Sun, 07 Nov 2021 16:29:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m6SHADWh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236116AbhKGSAx (ORCPT + 99 others); Sun, 7 Nov 2021 13:00:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236050AbhKGSAm (ORCPT ); Sun, 7 Nov 2021 13:00:42 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF7EC061570; Sun, 7 Nov 2021 09:57:59 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id ee33so53623767edb.8; Sun, 07 Nov 2021 09:57:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QULGmrTqCLxJGFukNsnY5+P3UKYk27qIk13ZoZ0RKo4=; b=m6SHADWhbziTvhHaZ0FeP+dpR4kT/KR7fVqo4gdL9DkEO20Z7csRzLVPdlfqdIBfQg TznVC3bOFTKk1+Q2lLgZDDhUHBz2gox7Jt4VWcPqciC9dKZcxh2rZJbA7W7vzvyB2Y+f cJvQPdrkSPS/giCPCssx5LFkxvJzDwxN1jCb3lpkuFAavjoCwpNuGaBwB70PsLVWbclW HnBw2MO0ZkXwFdhQ8a94ZsRsu9dHgCxTl8MLVI66HE+A2zQHFUAMWzPsV5BryVoRy4GK SUZ7bRZefR4ocnmrASCAzGuOW9lXD05n0BI4wKjF+MpDfUS3w0VyCP/ckPW9Okt2DOad e5fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QULGmrTqCLxJGFukNsnY5+P3UKYk27qIk13ZoZ0RKo4=; b=cUVrdWBD30+XgJpMF0NsWmE+Lltci7mvurJLZH+sWxScbZPwN8EeIz/XCoXoesZSGQ AbWffFhe05NphKjDWynkgR+CnTrhrHYU3cD43Z2X2/fiLWtBHrclpg6+gZSPWYVcOfzF ticekU2qwK69P+FPnpP9+oHJH71jICpjT6nLAfYGCcyZIWwVqaqjGJFzFnMUh0Ed/1+/ YiCNXXOEfUtOjnrdaeq4GtOH3VoRcANiF4xwIoF+I0q+1qR5jdIqZpH/eTvipVcwqNbh rUBMyAkSffwFLsHqvDEbv308Bh7a/8gK/IrvwnfHf0pT8MJRJ2le5YxKU/T868mQYJe/ szUw== X-Gm-Message-State: AOAM533LC0AYYNKJ+o4O5va+WZWusraOh2+4uoPC1kDG23woVlLna8dy j8lBlPmp2PaReuyPJxT9PDk= X-Received: by 2002:a50:e1c4:: with SMTP id m4mr99540306edl.307.1636307877663; Sun, 07 Nov 2021 09:57:57 -0800 (PST) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id m11sm4251182edd.58.2021.11.07.09.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Nov 2021 09:57:57 -0800 (PST) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Rob Herring , Jonathan Corbet , Pavel Machek , Ansuel Smith , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-leds@vger.kernel.org Subject: [RFC PATCH 3/6] leds: add function to configure offload leds Date: Sun, 7 Nov 2021 18:57:15 +0100 Message-Id: <20211107175718.9151-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211107175718.9151-1-ansuelsmth@gmail.com> References: <20211107175718.9151-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add configure_offload helper to configure how the LED should work in offload mode. The function require to support the particular trigger and will use the passed offload_flags to elaborate the data and apply the correct configuration. This function will then be used by the offload trigger to request and update offload configuration. Signed-off-by: Ansuel Smith --- Documentation/leds/leds-class.rst | 12 ++++++++++++ include/linux/leds.h | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Documentation/leds/leds-class.rst b/Documentation/leds/leds-class.rst index ab50b58d6a21..af84cce09068 100644 --- a/Documentation/leds/leds-class.rst +++ b/Documentation/leds/leds-class.rst @@ -191,6 +191,18 @@ If the second argument (enable) to the trigger_offload() method is false, any active HW offloading must be deactivated. In this case errors are not permitted in the trigger_offload() method. +The offload trigger will use the function configure_offload() provided by the driver +that will configure the offloaded mode for the LED. +This function pass as the first argument (offload_flags) a u32 flag, it's in the LED +driver interest how to elaborate this flags and to declare support for a particular +offload trigger. +The second argument (cmd) of the configure_offload() method can be used to do various +operation for the specific trigger. We currently support ENABLE, DISABLE and READ to +enable, disable and read the state of the offload trigger for the LED driver. +If the driver return -ENOTSUPP on configure_offload, the trigger activation will +fail as the driver doesn't support that specific offload trigger or don't know +how to handle the provided flags. + LEDs can declare the supported offload trigger using linux,supported-offload-triggers binding in the dts. This is just an array of string that will be used by any offload trigger to check the supported triggers and configure the LED offload mode diff --git a/include/linux/leds.h b/include/linux/leds.h index ff1f903f8079..eb06d812bc24 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -67,6 +67,14 @@ struct led_hw_trigger_type { int dummy; }; +#ifdef CONFIG_LEDS_OFFLOAD_TRIGGERS +enum offload_trigger_cmd { + TRIGGER_ENABLE, + TRIGGER_DISABLE, + TRIGGER_READ +}; +#endif + struct led_classdev { const char *name; unsigned int brightness; @@ -163,6 +171,14 @@ struct led_classdev { /* some LEDs may be able to offload some SW triggers to HW */ int (*trigger_offload)(struct led_classdev *led_cdev, bool enable); + /* Function to configure how the LEDs should work in offload mode. + * The function require to support the trigger and will use the + * passed flags to elaborate the trigger requested and apply the + * correct configuration. + */ + int (*configure_offload)(struct led_classdev *led_cdev, + u32 offload_flags, + enum offload_trigger_cmd cmd); #endif #endif -- 2.32.0