Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp720252rwb; Thu, 18 Aug 2022 10:59:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR57M0faZAJbFUJ6a5wz2bKmOvG0q2oM1T1veFrJdCLzkTOHc7Y2bbUJvPCP0iEdHk8IPnMH X-Received: by 2002:a05:6402:4515:b0:443:7833:3d7b with SMTP id ez21-20020a056402451500b0044378333d7bmr3053976edb.151.1660845548294; Thu, 18 Aug 2022 10:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660845548; cv=none; d=google.com; s=arc-20160816; b=FubH4fD8SNd85p4Gr+HUqtiwyq9BrzE5j70rQU4iwMcC2Ghip1uqsQHCA15r4D3Efa caGHsrBbiZCWwFVl8ZxsYTCdDjHlRwEIFk38Dr6gNzcJXSCjck5GJRwBCs5yyqaMMyoc o8PZ3i6L2nU3hLTemYE0axybb6t25f3nD9kTdMa2AwIIYgKA/qE7nYcvSaOnFtas7RZn XUU+TpW6PSty/6DebaRU3rPBxIjVRW4mVDEfyETgFvV1WT7Hs7ObTAB/Ivr1WZgzziT5 XlbrsOXKQl9ENLZ/2mhG99ARiArCaqEuEnxauqtDW4K1pUYy095KTi5pXkf9NpSGuSGJ K2Aw== 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:cc:to:from :dkim-signature; bh=AhXnn5P7B+qEuKegvM3Zeu5WplAgwTxSBxQK6/j5Xxw=; b=GXdOt611dv8uZ8Nj3FEJiHfZf/4v1260XUKE1iZ5JeretXooITq/RvhAXFovuUGHbO iir9WNwSyus2sn949Pdbw9+kvuJSCajPOtZ6gdnXVb82y/7Bp1tGq08GVEzD5OlOvV2n yhpG9piQJviFxm1TlZP4jk7EMIeeXSVfU26OdnpazbpyCOhusCHxvm2XDjunD48oGG1s 4dpIabdZScwAEJ8GT+2hzOspulWJyjrjN4hBKkSgR1KEueSKhnEcTrSMVodoq+QkE+G0 JdN6QVXgNIpykbjP2+bXnacpxf6mA5edO/bHb6QgwQUbrPJP5w0n1gdFVtGf9ZPfZX5A C6bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DI/wDz+h"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt27-20020a170906aadb00b00734c5ab8514si1228510ejb.151.2022.08.18.10.58.42; Thu, 18 Aug 2022 10:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DI/wDz+h"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344780AbiHRR0I (ORCPT + 99 others); Thu, 18 Aug 2022 13:26:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345590AbiHRRZy (ORCPT ); Thu, 18 Aug 2022 13:25:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA4FCE48; Thu, 18 Aug 2022 10:25:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4536D616FD; Thu, 18 Aug 2022 17:25:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 767AFC433C1; Thu, 18 Aug 2022 17:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660843552; bh=U4ulU7LUfIxOOKY+jPEQdeirsitxhl7mzZqSCLj9pLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DI/wDz+hwFetaviDPUx/S35ihafJz/fiirF4hzWGi7bbpJIGg0lMUybl5TenFCb/j JKqXVUHPN7WspTnqf7Efoo75RAUb8y3cHEwfZBT22+0Z76MdwvJSJ9zlVAR9Sl+wEm 5tOcALdJgW3DV5+62WeoqvaUTKkVx1DVfWl+tjnkj1zWqHMdOnnmphf8ypMqzgsmzx QSPHUXWyB646qiVqtHnR9l9E1AUBebDkaUyYWtM9NCKC8STKCs7nUl7ZqqxuckF4lz ouFexmlD9E1CAR0cNYa0GUttQwFXLGdGTdiYoV5X8mKgWj6uN8Y/Y82SWKEatrrFrs x1De1mfYJt6hg== Received: by pali.im (Postfix) id E05782868; Thu, 18 Aug 2022 19:25:49 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Pavel Machek , Rob Herring , Krzysztof Kozlowski , Linus Walleij , =?UTF-8?q?Marek=20Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] leds: syscon: Implement support for active-low property Date: Thu, 18 Aug 2022 19:25:28 +0200 Message-Id: <20220818172528.23062-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220818172528.23062-1-pali@kernel.org> References: <20220818172528.23062-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This new active-low property specify that LED has inverted logic (0 - enable LED, 1 - disable LED). Signed-off-by: Pali Rohár --- drivers/leds/leds-syscon.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c index 7eddb8ecb44e..5e605d8438e9 100644 --- a/drivers/leds/leds-syscon.c +++ b/drivers/leds/leds-syscon.c @@ -29,6 +29,7 @@ struct syscon_led { struct regmap *map; u32 offset; u32 mask; + bool active_low; bool state; }; @@ -41,10 +42,10 @@ static void syscon_led_set(struct led_classdev *led_cdev, int ret; if (value == LED_OFF) { - val = 0; + val = sled->active_low ? sled->mask : 0; sled->state = false; } else { - val = sled->mask; + val = sled->active_low ? 0 : sled->mask; sled->state = true; } @@ -85,6 +86,8 @@ static int syscon_led_probe(struct platform_device *pdev) return -EINVAL; if (of_property_read_u32(np, "mask", &sled->mask)) return -EINVAL; + if (of_find_property(np, "active-low", NULL)) + sled->active_low = true; state = of_get_property(np, "default-state", NULL); if (state) { @@ -95,17 +98,20 @@ static int syscon_led_probe(struct platform_device *pdev) if (ret < 0) return ret; sled->state = !!(val & sled->mask); + if (sled->active_low) + sled->state = !sled->state; } else if (!strcmp(state, "on")) { sled->state = true; ret = regmap_update_bits(map, sled->offset, sled->mask, - sled->mask); + sled->active_low ? 0 : sled->mask); if (ret < 0) return ret; } else { sled->state = false; ret = regmap_update_bits(map, sled->offset, - sled->mask, 0); + sled->mask, + sled->active_low ? sled->mask : 0); if (ret < 0) return ret; } -- 2.20.1