From patchwork Fri Sep 27 22:29:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 831696 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 3959418C031 for ; Fri, 27 Sep 2024 22:29:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476196; cv=none; b=Zn6XXt71nJm1GTm7kJMF7PpqNCAO16qrKDUb4bkNyCkUIiy0w2uaSy31FOrRER3jKI5uV8aRy0uuq6tDQGI6/f3U/RQzLudH0XpHTtRM19DEyb31vfQSzOVDZvHUTEaQVWizypQ30sxw3m9H9b6E2uo9ZWXn94L1i0IKjTLjJds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476196; c=relaxed/simple; bh=FmGcDe1p/XryRMot0XsEfBe1wWBOoapRPT+K+lRDZVU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PCfJSEYHf21W6EFsOuU1Sj0TiQt82WbJ7xmHkRvnW2s1W1/5WqnBb/kz8d05mKv/rHAbcuOkaruDhE7iqO46VaHt7+wcwmVPmhsRiIdewi5TTJ0d0HhOEH6T8bfDGWoUdv8+4oxb5E64YzRspuQEleRJ78PQbPUCX3IGXUjRhR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=v5CMLCZ9; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="v5CMLCZ9" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a8ce5db8668so411765466b.1 for ; Fri, 27 Sep 2024 15:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727476194; x=1728080994; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3LUVzEQIz/A5tXIUDtOQ9ez96BC3u8YRQCjYb/XLh+M=; b=v5CMLCZ96CVN8GhX801mFuZAszZjsM7C5Gj7zP9KftndCbjfPU9pFzBjE3tYiNdVRz pwMgsrToxhh80kf+z/cb/INye2ByscwHVbzgXhFXahp7g7ZdWjmSxfCCtLC2iLxAG7Ym 49UfpYluO0zqE0HxVVoCu4DDCXKG0MvH8IIW8qGDQ96zPvK/aRAykCmWeipPr1VdXOLb YRNQOZb2Nsp9owJg9WwY+KP1dzpuofHJbrTdW/hisGaWSwh7kuQjssbaOfbKZdmxSXUX xFp06pUYLxr/7hEzpQ5Trzqf/XLoHuG8NpZHc8Np7Al424UdebCF5XvDYSr1bF0PC6HO ocSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727476194; x=1728080994; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3LUVzEQIz/A5tXIUDtOQ9ez96BC3u8YRQCjYb/XLh+M=; b=GyjCLg1v+ph9nuFIVpblInz4MCJb5O1HuhKVWR+1j6q0leKSrbquzXO62YG2tRYZ1S nsJc2IffcibpuHX63KoTD7brJ9IwVCjsw7/4DWXZWRjrjI2R2gni2OH5kzuxaTWt9xjL Jhi2D9O0RSPB4VpY7jmPJ1+9zM9zhR2kvL69ehd2Jp5c6nqGh/XunvUoN2Dy7bXHIbim pz4H5vVXWny13JciXIDGOSncvgIqkPhIyXNTLbYy11jfi5xOxEBUtcP1DdwhqaiQn1al kpW42G1QP6Qd5IW0yH2a9tmQOyhW6Fvws7unCgN+M0xL81Fm+gu+gjj30f9kcsQO40Gh WO7g== X-Gm-Message-State: AOJu0YzpQtLIQYCqN4ayNLUCwZtsi/z7AfbiBgzT40i0Hkp1s5BXrf/r 0EpNgLiTAn7X/5Hif06xn66eUGtjYhuA/eBC+GbkOJXZhpDd2UkjkEwOix2cpj4= X-Google-Smtp-Source: AGHT+IHB0zTVjEfwaHCQx8PIwBJBJrhn37SfrjLIPeiADOfkCNOJ4wTJti1Tz9xOpDocnW+tseBUwQ== X-Received: by 2002:a17:907:930a:b0:a8b:ddf4:46f1 with SMTP id a640c23a62f3a-a93c4a98de5mr450042266b.63.1727476193687; Fri, 27 Sep 2024 15:29:53 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c29460eesm179504066b.119.2024.09.27.15.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 15:29:52 -0700 (PDT) From: Linus Walleij Date: Sat, 28 Sep 2024 00:29:47 +0200 Subject: [PATCH v2 1/4] dt-bindings: leds: bcm63138: Add shift register bits Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-bcm63138-leds-v2-1-f6aa4d4d6ef2@linaro.org> References: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> In-Reply-To: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 The BCM63138 family of serial LED controllers has a register where we can set up bits for the shift registers. These are the number of rounds the bits need to be shifted before all bits have been shifted through the external shift registers. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the $ref to u32 since the new property is suffixed with "-bits" and thus get standard treatment. --- Documentation/devicetree/bindings/leds/leds-bcm63138.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml index bb20394fca5c..b3d530c46061 100644 --- a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml +++ b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml @@ -41,6 +41,17 @@ properties: "#size-cells": const: 0 + brcm,serial-shift-bits: + minimum: 1 + maximum: 32 + description: + This describes the number of 8-bit serial shifters + connected to the LED controller block. The hardware + is typically using 8-bit shift registers with 8 LEDs + per shift register, so 4 shifters results in 32 LEDs + or 2 shifters give 16 LEDs etc, but the hardware + supports any odd number of registers. + patternProperties: "^led@[a-f0-9]+$": type: object @@ -71,6 +82,7 @@ examples: leds@ff800800 { compatible = "brcm,bcm4908-leds", "brcm,bcm63138-leds"; reg = <0xff800800 0xdc>; + brcm,serial-shift-bits = <16>; #address-cells = <1>; #size-cells = <0>; From patchwork Fri Sep 27 22:29:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 831110 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 D9E3F188CA9 for ; Fri, 27 Sep 2024 22:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476198; cv=none; b=oC6lnj31a1yJpKmQPDSkRKVWnXYGjL+sTHt/NKR50gChU0WejuqZWdd7/jNK3i3nPsvm5bKs3R/7oHGr4TVi/7SejrJbWqKFfon6kBll4qL1boDqOSLE5dMDF0/dIoVubnfXS/TBl6aqTxaFmEHbFDbRnqQxeGkQrlJ95sOXejk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476198; c=relaxed/simple; bh=Xtn246ffe+DO8hn0Ugf8AMOw+Lw1qO4c2sSOIr/ZryM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QIsnmiLqF5pPcm6xBgZ4F8tFZrVcQ3Es8S5uaU0OUBBbT/dtYrhasi8JhAr9TRqGs3ZRInfj30iTMGzFkRi2/Ho2XXUZj9AuWXg4ZHR0Y0dTI+YDJwTwHO+IU1HJq/qd5DRYHA8P7f8oAfQ9rToJ3zJlCFKzMMgvz31674bJ4Ug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WDOFKvIv; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WDOFKvIv" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a8d60e23b33so350775266b.0 for ; Fri, 27 Sep 2024 15:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727476195; x=1728080995; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sWnKbsxefkmEHGrZFlS1qac5gpq5RncaWSP6AZtVnA0=; b=WDOFKvIv4neao9vZQtslmU4Jlvl+KVpFCpzKYIfNTWALJjr6ay1cacMNTQiL4yaImn HoqX+qUzps9dfLlJzpeo7ksl7iPi7lOxbN+QDL8vBTfvD+DxZSniMhHc0ONULAG/yfxE 1ROCQJYMSI7uQF9HpeqQVUY8ZReQ3CfIeLtG/Uv3jl2hxYgmEWHp7QV/CQyjRtKYfKAw NhXI//yAhjkDzJpapZ5osV/MLjWnejncgti+JBqoHN6FeIldc3VrrJJSkxFO6JWoiaPi tiTj2HD6MH7ZZhTlEPH2UeJa3iLsYEHKQ3PdI+Q5nCCuzYbkIO+VLpSxKliVru0WFdRb O+Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727476195; x=1728080995; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sWnKbsxefkmEHGrZFlS1qac5gpq5RncaWSP6AZtVnA0=; b=GGhEo1MmAPFcRF7EMAI21fnU7wstOaJMslD7wUwDNUkfCUuXZ+vQTThoEjJ5rfX5dh cXuXCB2/TxdK91mIPNEzyHFu8la/igNHo8CJSpxeVs5qva1p5CaG5sCfeoZ/0wE8bsTe VywwZzODz8YbFSEryn3wRq5PPy1wxx0aITVnqRzn3Hk/XFObvPaL/fuVFwQV8GLlamjI V4DdxfAa0IuNv54w1U7g8Gs0m+Y6aHqlb+ZZ6y/WaGQZ6gc+XgBj1xXQoPNKXqjlEApu x+3W42UR1riE5r2bl7mDjfTVTw0m2/1TF+zJkE64FWAkICO/X1qtx134hnBhLysrdLo/ izFg== X-Gm-Message-State: AOJu0YwBgHAN0p8HThyD/dffkcsq5HEpuSpZqMJWrSo0jbq4FD5AASdO udE4XEnvsJrxDaZB5Q3VDzW/s+wX6FGgNk0sgZbWu2vKMGCG/JWc30iehivovOw= X-Google-Smtp-Source: AGHT+IEOTcEGxxl1GF0PinK1NeaeqxJkKelV79iOWepyZC9Lm/huNFkmzogsSUwTSIpX/ag79RoKAg== X-Received: by 2002:a17:907:25c3:b0:a91:158b:122c with SMTP id a640c23a62f3a-a93c496952emr400472466b.38.1727476195059; Fri, 27 Sep 2024 15:29:55 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c29460eesm179504066b.119.2024.09.27.15.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 15:29:54 -0700 (PDT) From: Linus Walleij Date: Sat, 28 Sep 2024 00:29:48 +0200 Subject: [PATCH v2 2/4] leds: bcm63138: Use scopes and guards Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-bcm63138-leds-v2-2-f6aa4d4d6ef2@linaro.org> References: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> In-Reply-To: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 Use scoped helpers and guards to handle DT node iterations and spinlocks. This cuts some lines of code and eliminates common mistakes (such as the missing of_node_put()). Reviewed-by: Florian Fainelli Signed-off-by: Linus Walleij --- drivers/leds/blink/leds-bcm63138.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/leds/blink/leds-bcm63138.c b/drivers/leds/blink/leds-bcm63138.c index 3a5e0b98bfbc..374f68f4f277 100644 --- a/drivers/leds/blink/leds-bcm63138.c +++ b/drivers/leds/blink/leds-bcm63138.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2021 Rafał Miłecki */ +#include #include #include #include @@ -125,17 +126,14 @@ static void bcm63138_leds_brightness_set(struct led_classdev *led_cdev, { struct bcm63138_led *led = container_of(led_cdev, struct bcm63138_led, cdev); struct bcm63138_leds *leds = led->leds; - unsigned long flags; - spin_lock_irqsave(&leds->lock, flags); + guard(spinlock_irqsave)(&leds->lock); bcm63138_leds_enable_led(leds, led, value); if (!value) bcm63138_leds_set_flash_rate(leds, led, 0); else bcm63138_leds_set_bright(leds, led, value); - - spin_unlock_irqrestore(&leds->lock, flags); } static int bcm63138_leds_blink_set(struct led_classdev *led_cdev, @@ -144,7 +142,6 @@ static int bcm63138_leds_blink_set(struct led_classdev *led_cdev, { struct bcm63138_led *led = container_of(led_cdev, struct bcm63138_led, cdev); struct bcm63138_leds *leds = led->leds; - unsigned long flags; u8 value; if (!*delay_on && !*delay_off) { @@ -179,13 +176,11 @@ static int bcm63138_leds_blink_set(struct led_classdev *led_cdev, return -EINVAL; } - spin_lock_irqsave(&leds->lock, flags); + guard(spinlock_irqsave)(&leds->lock); bcm63138_leds_enable_led(leds, led, BCM63138_MAX_BRIGHTNESS); bcm63138_leds_set_flash_rate(leds, led, value); - spin_unlock_irqrestore(&leds->lock, flags); - return 0; } @@ -259,7 +254,6 @@ static int bcm63138_leds_probe(struct platform_device *pdev) struct device_node *np = dev_of_node(&pdev->dev); struct device *dev = &pdev->dev; struct bcm63138_leds *leds; - struct device_node *child; leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL); if (!leds) @@ -280,7 +274,7 @@ static int bcm63138_leds_probe(struct platform_device *pdev) bcm63138_leds_write(leds, BCM63138_SERIAL_LED_POLARITY, 0); bcm63138_leds_write(leds, BCM63138_PARALLEL_LED_POLARITY, 0); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { bcm63138_leds_create_led(leds, child); } From patchwork Fri Sep 27 22:29:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 831695 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 6A6D219CD18 for ; Fri, 27 Sep 2024 22:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476200; cv=none; b=VWGi+6W+ExMFCTPSstRHpGH/JXTQMDaaRWutNGtcSz9mGNETvSJp6/vg8gS+5MN/Snun1+3zGx5JJECxcoLZpRKoJ5oymEqX2OHSN97FaXSa7nVnbfFngV5BTNRb5FJ1IAoQGEk+rNz3ZH+XQid766ttujYCPJ7GeIUUaltxfbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476200; c=relaxed/simple; bh=FnmLOeDSpJX+e4oZfKM4ssmMezMCZY+ZhBPl8+fQFa0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MivOgP51sRtdeIWE6vv+LyJHDiwGo5pHEcq2P0OY0xDKDiR4tNDgkpBBueZggVuxpbrOudTVn0D9Q8gjMWQ/cYB9RS95LHNNXiSrUIQjB5Ix/Bmk1fEpK2Vlm7EvLdpULj0NGWAM9GTwLn18WiP6DnctBTYjA818Jw1S5HfkDws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NP1PZIeP; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NP1PZIeP" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a8a789c4fc5so626288966b.0 for ; Fri, 27 Sep 2024 15:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727476197; x=1728080997; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q0Xo7lyATMDsOi/JTMW6RiHHyZurrxixH5uKKnJ9YLk=; b=NP1PZIePxhKlGXZGCEbZ0uDBJrpYyypoh0TfXPli6reCRZdqA6J1qU1p5bS4lbkIRM Q9h7SPW7kUHyeiQoyAq18ZtIRKJgWfgq00wkuveqRXzQ2EWz+e8pEVyBsWw/FAIL4AZL h3y18+gGs/s2SJp4FCOlBhLCK26OdW92xnq9Dyi4Gcc65cyiXvJZ85BoSJ0XwNb8emoI y/VoAwFTFc2PHV8LScQKSwyfpk7UF8wlEUAF3K4yu35z0pwfNXpSsHv1P4EQdl8u0l3D r/BtLf2lCM7Fd12T8YoAFrIi9uUBSNWEVOaLXxuFbbOdtD2mFLuxJr0aTuIGrhYoCSuE 5cIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727476197; x=1728080997; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q0Xo7lyATMDsOi/JTMW6RiHHyZurrxixH5uKKnJ9YLk=; b=tJnH885XGbhhGmxt4WZHhmNABL8Hd3FwbIrffB6S20y6jop4g4bUcVnQVX/jr368p0 oqGBB5Wxtkvx5oy9Gj3nQqI6xl8ce4w4Kz9Rdq+S4l6385OohNKgMu02JN4amJQ0FjQD HEsTgSLju5h8OPy7jPSWLgtz3S+i8enP2uA1TMsypXxyWsFcfI7lmM1cZnyvdCVJXNtf yxRTttSHKErvQkt9tmDP1ex3MEW8EdDLsgwPjulDvgotrfBsaioMIe5YF7xGVvpQWlNZ tn9oWN/mI59J+ubbhGkzi0m7k782O6zj63brzqWZUfUXGVOP02DSZXBaBSY06Rz8CJF8 ykMg== X-Gm-Message-State: AOJu0YyPV4wPBCdeMthyQsZ2pkJCRQv2Ua74LG+DxgBKuOK+6x/vcQ5X 872lzVvLCp956glWM8Sd3r8sLlV14xPWgjYi7jh4Ge4vOywG/jJmQprYd57wjoc= X-Google-Smtp-Source: AGHT+IGBFeYfR6SQYm0jjvz1V3boHDBtBDgmMkB4kB1X48hs2GlTIo+mSgOWRldYWOv3oxGSC9VMDg== X-Received: by 2002:a17:907:7f17:b0:a8a:9243:486 with SMTP id a640c23a62f3a-a93c318688amr553077966b.21.1727476196623; Fri, 27 Sep 2024 15:29:56 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c29460eesm179504066b.119.2024.09.27.15.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 15:29:56 -0700 (PDT) From: Linus Walleij Date: Sat, 28 Sep 2024 00:29:49 +0200 Subject: [PATCH v2 3/4] leds: bcm63138: Handle shift register config Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-bcm63138-leds-v2-3-f6aa4d4d6ef2@linaro.org> References: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> In-Reply-To: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 This adds code to optionally read the width of the shift register chain from the device tree and use it to set up the register controlling the shifter hardware. If the property is not present, the boot-time default is used so existing device trees keep working as this is what they assume. Signed-off-by: Linus Walleij --- drivers/leds/blink/leds-bcm63138.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/leds/blink/leds-bcm63138.c b/drivers/leds/blink/leds-bcm63138.c index 374f68f4f277..9fe1af156c80 100644 --- a/drivers/leds/blink/leds-bcm63138.c +++ b/drivers/leds/blink/leds-bcm63138.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2021 Rafał Miłecki */ +#include #include #include #include @@ -254,6 +255,7 @@ static int bcm63138_leds_probe(struct platform_device *pdev) struct device_node *np = dev_of_node(&pdev->dev); struct device *dev = &pdev->dev; struct bcm63138_leds *leds; + u32 shift_bits; leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL); if (!leds) @@ -267,6 +269,12 @@ static int bcm63138_leds_probe(struct platform_device *pdev) spin_lock_init(&leds->lock); + /* If this property is not present, we use boot defaults */ + if (!of_property_read_u32(np, "brcm,serial-shift-bits", &shift_bits)) { + bcm63138_leds_write(leds, BCM63138_SERIAL_LED_SHIFT_SEL, + GENMASK(shift_bits - 1, 0)); + } + bcm63138_leds_write(leds, BCM63138_GLB_CTRL, BCM63138_GLB_CTRL_SERIAL_LED_DATA_PPOL | BCM63138_GLB_CTRL_SERIAL_LED_EN_POL); From patchwork Fri Sep 27 22:29:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 831109 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 28071195FFA for ; Fri, 27 Sep 2024 22:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476202; cv=none; b=oFClVnGgL169D09YxnDX46z+XewU9ihYk6Poikwvqp/E+PhuIVwh4OHgKZH88sj8Pg+q0TbPl7H32dSNfoOdyJmP1uVpUd/vtZAW55rJyh3U+tgGFdoDojcE24p//Ys3VLlhdRF/Bz4LrfUxejNpg0TjCGUR7e6et1nQMVVrYNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727476202; c=relaxed/simple; bh=VzOZ0OjBtRVKiOzN7FNFk/cdUjMZXgMfwiyK8St+tx4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c0l7vuQ9P3CMMQLCKsx2T1GnZjUhhLgqHQkCMsHMWhwVz11plujuhZ4LWm76AdvEUQ6KFJ44OCio1j19piL2281rX7NUemk8PnDG94Oh4p9O2wJzAhxKGys+K+ddBON3mCj1n07bA01pLDSkCMw1Ay3aJAqAA1JetD24y5pTbq4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=g+ggPMjk; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="g+ggPMjk" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a8d0d82e76aso375667166b.3 for ; Fri, 27 Sep 2024 15:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727476199; x=1728080999; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Ch6AGylS4Nguwv4PhgtiCfmSrgOswaxxBAnBe3xKbKw=; b=g+ggPMjkU3RL8s+MhAUmRxYT6FvZacaAdTcd4PXtoWPsW6raWyJTVz6ff9+dX7Av5n UbrYvE0iTYwW9Fj0E+ROQ3+WXNj0zHWoZ7CriVSIAKgPaOaI/emRHjdwnrQ1e9E2ufWS OjkHrGLIXHDx1GSrUTVhB60nymzk4zRrvqh8/p4cT6trrqRfmsJ2k5NHxpJCKkR55H/h 8Zv6RlUUZZ5KxfmYh8IZ3NsUFEiRNnCKnmaT5Pz3cQrFAJ2ASsHNXhoP5iZjYLaRKjaH Iwz0FSJOQtaEog3dpayFpLdDXU0e/KaV2MMPh241K5NERwxi6USLnZ5+viuJTJGO0WY5 fPUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727476199; x=1728080999; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ch6AGylS4Nguwv4PhgtiCfmSrgOswaxxBAnBe3xKbKw=; b=GkhB0Rx7i3p6En80M8N10ieeXi4/hoB+r6dPxzuHkU665M9OaF/yk1TDQJ0kSfI+zD DbEgA+UvND2+sOl7X1Kl30bO+ETz7utMAf5cga+OMgMmKuU7n5tu/VJCWslwx37Wnqta SOCgqUpvD/nXFbrXC9t9/n4y81m3RUk0m3TwsDYWnFVtwo796O3QwBbI/Att2TdQ9vOd JKwtFkWeBn7uyTxZanSg4b8uTurbvo0+NszD5DLJR74TzWg3uTayyeZGYHGpKluC5Umg QIpoYFxiilxc+uV/zO99CPGnoPZrWeBlXKTZgiu+UPpGVRx4ySJpxnCQxyh1XQYOvmv7 IIeA== X-Gm-Message-State: AOJu0Yzl/3JaNf0nAHKd64Y/1DLKM3Cq0cULk/1yuMTw24JmaTFpgHi3 lrJ73y5xGHQDcpXKrcxH1SehIO+IkuNfnMz5uavxWZeZ7Wtcx4RAwo8Y3Re6wgQ= X-Google-Smtp-Source: AGHT+IHv4uMBRChUtKmto4PiKOdp1c4MseKfg6DWruwE+gJLuyChTJZenIMzqOsEUsbfKWPmZB7EGg== X-Received: by 2002:a17:906:4788:b0:a86:9e84:dddc with SMTP id a640c23a62f3a-a93c4a98dd7mr452734866b.61.1727476199423; Fri, 27 Sep 2024 15:29:59 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c29460eesm179504066b.119.2024.09.27.15.29.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 15:29:57 -0700 (PDT) From: Linus Walleij Date: Sat, 28 Sep 2024 00:29:50 +0200 Subject: [PATCH v2 4/4] leds: bcm63138: Add some register defines Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240928-bcm63138-leds-v2-4-f6aa4d4d6ef2@linaro.org> References: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> In-Reply-To: <20240928-bcm63138-leds-v2-0-f6aa4d4d6ef2@linaro.org> To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 The Power LUT (Look-up Table) register base was missing, also add the bit define for sending serial LED data in reverse order, and use the BIT() macro to define the bits in the control register. Signed-off-by: Linus Walleij --- drivers/leds/blink/leds-bcm63138.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/leds/blink/leds-bcm63138.c b/drivers/leds/blink/leds-bcm63138.c index 9fe1af156c80..190d9774164b 100644 --- a/drivers/leds/blink/leds-bcm63138.c +++ b/drivers/leds/blink/leds-bcm63138.c @@ -21,8 +21,9 @@ #define BCM63138_LEDS_PER_REG (32 / BCM63138_LED_BITS) /* 8 */ #define BCM63138_GLB_CTRL 0x00 -#define BCM63138_GLB_CTRL_SERIAL_LED_DATA_PPOL 0x00000002 -#define BCM63138_GLB_CTRL_SERIAL_LED_EN_POL 0x00000008 +#define BCM63138_GLB_CTRL_SERIAL_LED_DATA_PPOL BIT(1) +#define BCM63138_GLB_CTRL_SERIAL_LED_EN_POL BIT(3) +#define BCM63138_GLB_CTRL_SERIAL_LED_MSB_FIRST BIT(4) #define BCM63138_MASK 0x04 #define BCM63138_HW_LED_EN 0x08 #define BCM63138_SERIAL_LED_SHIFT_SEL 0x0c @@ -35,6 +36,7 @@ #define BCM63138_BRIGHT_CTRL3 0x28 #define BCM63138_BRIGHT_CTRL4 0x2c #define BCM63138_POWER_LED_CFG 0x30 +#define BCM63138_POWER_LUT 0x34 /* -> b0 */ #define BCM63138_HW_POLARITY 0xb4 #define BCM63138_SW_DATA 0xb8 #define BCM63138_SW_POLARITY 0xbc