From patchwork Tue Oct 15 15:14:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 835672 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D7EC1CBA07; Tue, 15 Oct 2024 15:14:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.89.224.132 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729005271; cv=none; b=gEVrwShOZHYdc51HELsLvw3bBITW4X0OJnwS+gDA+kD4/uTKMe5WUzP7ECVMOtqkXYFSsLjUoXz0QorTT7W2qvU6Jjt0zxRw5j/D2uGALPGuNczZmOgRi6+cXOfnM+UXrzV23WXmJrUG3H3ktPhEt+lOHSZS5zytKNKObNvfrg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729005271; c=relaxed/simple; bh=lazf32CoxSyj614cm2Mrmcr74+H3vT0Umdqs2/LXc+I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XL0PwrY4UJ2BST7iDvqjbHydXQ+TWvj+zYNqzhJ7hChjvYFvnG0T5GnHiyAfsOJs9214cat4Hlmjt06U1YE+y91jbKFMDmSOVVjxDFNnqiWKiVcQkDns2fdkvFwt/RtLhD5mijLS81Mt82eNTGhKG4ZYsB2pUHQYmGiuIBZgnQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com; spf=pass smtp.mailfrom=salutedevices.com; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b=LTXOS2p8; arc=none smtp.client-ip=45.89.224.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="LTXOS2p8" Received: from p-infra-ksmg-sc-msk02.sberdevices.ru (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 9BA69120019; Tue, 15 Oct 2024 18:14:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 9BA69120019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1729005258; bh=DgHLH+41zl5GK77OYraBFgcXwbuWqP38YKFjixubQRc=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=LTXOS2p8sWLts9zxfJnFdotMtxTQGpI9D+PGP0nEuc44NXMl5JYlqz5HSZgvN98Bd qgiczDSGtxgA7VccwP5KhnZ9XhCu83k/lNZ4kwkQQmE9eOKvgQLTb3cNgzYBhNky7W V8Ft9kSp5Mf61hIew69UyqmHbRNn1V9UzKferKsn+TStFWehCOR9lOlPMJH6QayCck Yt52ZJmN82bdSnaC8nb6N7UxhiCcTX2AD06oWgCm/1XXMR+LxPimk9wC/w9DUXyW2i TYIuBnb7insLAo9qgOiNLCtqZWkAhzgQjtUFUTcNCa4SbI1rMx5fK4vH6RhxjorxhT 6VA7Hv3kyTptw== Received: from smtp.sberdevices.ru (unknown [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Tue, 15 Oct 2024 18:14:18 +0300 (MSK) From: George Stark To: , , , , CC: , , , , George Stark Subject: [PATCH 1/2] dt-bindings: leds: pwm: Add default-brightness property Date: Tue, 15 Oct 2024 18:14:09 +0300 Message-ID: <20241015151410.2158102-2-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241015151410.2158102-1-gnstark@salutedevices.com> References: <20241015151410.2158102-1-gnstark@salutedevices.com> Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-a-m1.sberdevices.ru (172.24.196.116) To p-i-exch-a-m1.sberdevices.ru (172.24.196.116) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 188453 [Oct 15 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 39 0.3.39 e168d0b3ce73b485ab2648dd465313add1404cce, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; smtp.sberdevices.ru:5.0.1,7.1.1; salutedevices.com:7.1.1, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/10/15 13:03:00 #26756955 X-KSMG-AntiVirus-Status: Clean, skipped Optional default-brightness property specifies brightness value to be used if default LED state is on. Signed-off-by: George Stark Acked-by: Rob Herring (Arm) --- Documentation/devicetree/bindings/leds/leds-pwm.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.yaml b/Documentation/devicetree/bindings/leds/leds-pwm.yaml index 113b7c218303..61b97e8bc36d 100644 --- a/Documentation/devicetree/bindings/leds/leds-pwm.yaml +++ b/Documentation/devicetree/bindings/leds/leds-pwm.yaml @@ -34,6 +34,12 @@ patternProperties: Maximum brightness possible for the LED $ref: /schemas/types.yaml#/definitions/uint32 + default-brightness: + description: + Brightness to be set if LED's default state is on. Used only during + initialization. If the option is not set then max brightness is used. + $ref: /schemas/types.yaml#/definitions/uint32 + required: - pwms - max-brightness From patchwork Tue Oct 15 15:14:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Stark X-Patchwork-Id: 835671 Received: from mx1.sberdevices.ru (mx1.sberdevices.ru [37.18.73.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DE851CB9F0; Tue, 15 Oct 2024 15:22:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.18.73.165 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729005766; cv=none; b=tCMvbi0bWsA3ywS8MrcVx9M03JpGjXV7er7sSaCDCFdWn3JXkRxbNAKAF0CDtUiPmjYGAAQC6RQ9Wbfx7dOmf1BCHN2sNiB99/d3q+p6nJqct3VhI4e0Ij0kxpovdqV2/qRspfxEp8NdyDVZFl24UzKkaw8PRyV7EF46C8Vazic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729005766; c=relaxed/simple; bh=V/lSdhZG5JQdZTKZUF2yHDoCzCh4qnhs8hMlIfBsvJQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ON3O0g43l5qKsxMkb/lovBwgOwI9BgSuf5wH4I4luFIDFPfgq+xvChXDDe7JVrm1ka3YTwwSyZFl+QJycVU6pz9jGaK2si4A7tnFWNPsHpDIvEk1n3mtcgSVzIhp++FJH+basJyt4wJbM5OKetrzMKYZWVEXzUeewOnFZJLpb3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com; spf=pass smtp.mailfrom=salutedevices.com; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b=dBA0OsQg; arc=none smtp.client-ip=37.18.73.165 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=salutedevices.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=salutedevices.com header.i=@salutedevices.com header.b="dBA0OsQg" Received: from p-infra-ksmg-sc-msk01.sberdevices.ru (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id C45DC10000B; Tue, 15 Oct 2024 18:14:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru C45DC10000B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1729005258; bh=W+KmumfI3s3WpmWV3OWJsuZ0UfZfjFsxZ9apYOIiG2w=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=dBA0OsQgzVaaOLxU3KTV9Zpl431KR15/Kqsy1zwihxCC6lzk9ztagdkm6eVc8ot1I MinCvPJwKQ4j+A6hdrSTshGcgEwknbJPc3dO7mqr1jNRXOv1U8WgbbMMPoEo1BD4qX WjTzwSGsVvNw+BH1kwZk+gceTLcGsgfK5ScvmkX3rMCrULI033KTvUF6u9u+OauNK3 HfoSlcBynlYAhgi9dyG2Br9eqqxP2OF1gonol2FsLXcC+m46Fc6eBFnm9do3+BgvoN wonEFrWkQVM6uYCGBuQG8vDchtf5spCiu8mOOtiPKExE1fC0+ZetPHpnaB+ZJwuO5Q F8mdkTuEyh/5w== Received: from smtp.sberdevices.ru (unknown [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Tue, 15 Oct 2024 18:14:18 +0300 (MSK) From: George Stark To: , , , , CC: , , , , George Stark Subject: [PATCH 2/2] leds: pwm: Add optional DT property default-brightness Date: Tue, 15 Oct 2024 18:14:10 +0300 Message-ID: <20241015151410.2158102-3-gnstark@salutedevices.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241015151410.2158102-1-gnstark@salutedevices.com> References: <20241015151410.2158102-1-gnstark@salutedevices.com> Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: p-i-exch-a-m1.sberdevices.ru (172.24.196.116) To p-i-exch-a-m1.sberdevices.ru (172.24.196.116) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 188453 [Oct 15 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 39 0.3.39 e168d0b3ce73b485ab2648dd465313add1404cce, {Tracking_from_domain_doesnt_match_to}, smtp.sberdevices.ru:5.0.1,7.1.1; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; 127.0.0.199:7.1.2; salutedevices.com:7.1.1, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/10/15 13:03:00 #26756955 X-KSMG-AntiVirus-Status: Clean, skipped When probing if default LED state is on then default brightness will be applied instead of max brightness. Signed-off-by: George Stark --- drivers/leds/leds-pwm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 7961dca0db2f..514fc8ca3e80 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -65,7 +65,8 @@ static int led_pwm_set(struct led_classdev *led_cdev, __attribute__((nonnull)) static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, - struct led_pwm *led, struct fwnode_handle *fwnode) + struct led_pwm *led, struct fwnode_handle *fwnode, + unsigned int default_brightness) { struct led_pwm_data *led_data = &priv->leds[priv->num_leds]; struct led_init_data init_data = { .fwnode = fwnode }; @@ -104,7 +105,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, /* set brightness */ switch (led->default_state) { case LEDS_DEFSTATE_ON: - led_data->cdev.brightness = led->max_brightness; + led_data->cdev.brightness = default_brightness; break; case LEDS_DEFSTATE_KEEP: { @@ -141,6 +142,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) { struct led_pwm led; + unsigned int default_brightness; int ret; device_for_each_child_node_scoped(dev, fwnode) { @@ -160,7 +162,12 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) led.default_state = led_init_default_state_get(fwnode); - ret = led_pwm_add(dev, priv, &led, fwnode); + ret = fwnode_property_read_u32(fwnode, "default-brightness", + &default_brightness); + if (ret < 0 || default_brightness > led.max_brightness) + default_brightness = led.max_brightness; + + ret = led_pwm_add(dev, priv, &led, fwnode, default_brightness); if (ret) return ret; }