From patchwork Fri Sep 20 21:59:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 829944 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 72D6C17CA1B for ; Fri, 20 Sep 2024 21:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726869557; cv=none; b=Yihk12jwyZRzK/rJgX04Koj9p11Jz0tB2l1ytPvU0TSAQbC4coMAENiccwxu1DH1hvo2WOcTYourDhWqwKDLH30uSfM6oua0fy8xKNHJabEoFeghbTXtLShgy+0EIY6Hn+stqRRLegXUo7ECwH2lVmo/CkAoLznE8xLoOavb/38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726869557; c=relaxed/simple; bh=lUeowZsuetVPiSHDEbEzNurIe9ysnNsSoEY4sOMCr4M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uJ5rjeAg3r6FvQG6GJit8lhcOPQySypJbw+RUiCBAW5sgk678Y6kMRo4rlhGF9BvWJck8xy9ovRebCOCkLnuBKqWyuBR+HGSsSbbVfmzAP9adgQsP/xPbCbuKBziL/1i9C9vsnYa+SVKUP6mUOAuH6ezT43IfvbM+tuclnw+CxY= 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=AvTKklaz; arc=none smtp.client-ip=209.85.218.41 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="AvTKklaz" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a8d2daa2262so279749366b.1 for ; Fri, 20 Sep 2024 14:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726869554; x=1727474354; 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=xu7r0984CtbTq2n9dKs5JPNziAceYOtF1liwcsGF7Bc=; b=AvTKklazhNuziG74RQ1o45tZz3kqYNxtF4fBQO83jaVA9Wb7l2CX/lL596bVCqANR+ jH8qXDNne+nW3q2cNze/BnmN1PlkC6nyVCpvW42NzbXmxtUDYhHt1Bi66Zt5p5BiiiuV g413TsMnPYIWEwfetgDy19QJvr95IZfXmnKixnhUpTmKqORzmTQ6jzPKnBYlJOZoEgYO Y1p/SfYVFANfo5Ge3wNwRKIkugWDa7zI3ngTlOohiY3ewvqkN+b9aszJzj0PoAniUMsg JRH8/xg+i5gtCBKp6ljjg42m1hCerjVuxPDmIFl/CCNRD9+RGHtyO++HkUYuI+SY+5Oi cqjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726869554; x=1727474354; 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=xu7r0984CtbTq2n9dKs5JPNziAceYOtF1liwcsGF7Bc=; b=mzsHBCgbztdw5ENax8g/wUpHK67Mcj64hsLJdWr0OV2UNHkgVX+E6POv8zsEYbDwgW hrnHH7YG31WsnkkfngeyhjEMcogi+X3C8kjxcD0oee75lQNCxiJdwxKG42cUZH4V0+U+ bi9ci0eL53TEa+k2MN9myqz/8p+SBDoNfhb5Twra0BxZZoKTc+/fTRfDUNkJ+397rwBG dpR317nqHiDTBSN+dBzdJbaS69s0WvUe94vB3GuWoJi/T6kDl7IB/JyUtb/sLfuO/bfJ LEvfh/3wHKKUfqeUjchewhbvf0CKslUX/S6PYGZ0jmagVQ0z/AHnApZI03lHzx/XtB0C bFzw== X-Gm-Message-State: AOJu0Yw0PIIp5/IxV6zPaonvMgSnD4AcAGJF6ze8bbUN3ZCZBWeOK1fA kgWf5VmTuf0sfIjyjTJeLZNaqgfKxr0tDujjuk05SPrI8EvFWAREqvUo59MgG00= X-Google-Smtp-Source: AGHT+IH2PEu4pnjfpc5VAgi0Jk5JwhFWIMQJgd6STqWnsq0CSHKCP8pK/ncoPOoMq32YlSiPLi8meg== X-Received: by 2002:a17:906:bc10:b0:a8a:6db5:7e42 with SMTP id a640c23a62f3a-a90d4fdfe74mr391446866b.9.1726869553220; Fri, 20 Sep 2024 14:59:13 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612b3a04sm900617766b.125.2024.09.20.14.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 14:59:11 -0700 (PDT) From: Linus Walleij Date: Fri, 20 Sep 2024 23:59:03 +0200 Subject: [PATCH 1/4] dt-bindings: leds: bcm63128: 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: <20240920-bcm63138-leds-v1-1-c150871324a0@linaro.org> References: <20240920-bcm63138-leds-v1-0-c150871324a0@linaro.org> In-Reply-To: <20240920-bcm63138-leds-v1-0-c150871324a0@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 --- Documentation/devicetree/bindings/leds/leds-bcm63138.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml index bb20394fca5c..d27148279ead 100644 --- a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml +++ b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml @@ -41,6 +41,18 @@ properties: "#size-cells": const: 0 + brcm,serial-shift-bits: + $ref: /schemas/types.yaml#/definitions/uint32 + 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 +83,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 20 21:59:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 830081 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 4EB931862B3 for ; Fri, 20 Sep 2024 21:59:16 +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=1726869558; cv=none; b=IdFiH/ctfRuSh4QNka8zCQlKXUMz5ejngMxDGF+R01Arax/lcKdRNzcvzfyFFo4WTI71fQ2j4CLj4a4+84+H0d80Mg/8NzIcXcyQQ5f8KnY89v0L6ucQVRR0Djk0uHwO+sHmy/5B0EpyNsOivyGEcPlm6DNeouV5Np6JjHU22wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726869558; c=relaxed/simple; bh=gXl6DeY/9dMT9uXw7AqViTblnZhMwQSRd5v3XKQfaTU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NC4LC051am3BvqSPYxCr2PY9MotlKoJBtl/VKpNjP81WLxPCwf2tJRYwPjtrGdXjFI0G9D9l2EChS8wrByvRjwHZ5VMMRPJ5zAQitRhvp2dl7ZwKy98WNGP6SHTYFrlG36Yn7YBG5bc6HPtnTwmFeyj3ia3kzVtpbUsybaLc3NE= 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=tuSEMe9i; 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="tuSEMe9i" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a8d2b4a5bf1so324909166b.2 for ; Fri, 20 Sep 2024 14:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726869554; x=1727474354; 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=8/JfYrX/aNtfPTLK68m0sSubqj4AyYAOoUh1lb0Sm34=; b=tuSEMe9ijExJCjnQWwZfrB2hsuaxZZsBD+X/HJow6BosrQjVae+CWAYTV/2eh6p3ld m4wNBB3r2Jnug+HwGhiSnwAdN7d1VvlqdBy7HE5X5BvoaJa8ZnVK4qTD4Two1RY9/4+B 33TAno44QMMffgHQ00/OHaLJhdls9ebRTef9TQMhRWJoBvyAndNtYOFjuhbflLmMh1Gw RyRT4cbaVLiUNPo62WT0xSVwEoesy7ss0tTyCylWp0UIAicW2yZ13PwBBUJ93mqySTUX fImNtGQyt1hXdCTmbREiDUyCYVMYW24MCUb5diOpZK/1B0wNVIEZlbrUEVHgRpYdkP/k m0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726869554; x=1727474354; 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=8/JfYrX/aNtfPTLK68m0sSubqj4AyYAOoUh1lb0Sm34=; b=lZ9CZaY9b6L6CYEkJ8iL+UAta4M07KPpBMBtlrLesqUMIhEQvCZw2oAMEogg3VM4E0 5IwAp+0l+tmnLoKK1MWKHtfufwWtdcStAv53yE09foTydPsqyA5Nl0+p1rJrSFEKkwb7 95zZQXK+a5jPBgLtIyCyfgCFRZqrAqJ0X1sLs5u3t+WvR7FrrEN6pbd4R1ohaOIBMye7 CvH3Gr9GWVMfJKNYgXcOL1baLyXv/dOHP8coOqiAWZj3/1IgqDFIt9N5OyV3x019BVOL eTHIp1NP9CBMlM8ChHVJzfWMr6fhe7xw+TN7ezk6kuWTjktKX2YDvzBKeKJPtbEeelkF j3GA== X-Gm-Message-State: AOJu0YzN1imLcw0yXqjTl87wkSo0xaDbzaDPc0c2W/JmxyIKfYrz6eac Hc2YuE59Jjjf8pWy3LXSOJofXB9cWVBuZ8qLpThKcmkrDKYXYjG4ErfXJzc++8k= X-Google-Smtp-Source: AGHT+IFXdJ1xKzR//xbZgTZ9zcz2hn5EODZNg6u+Uq6l4/z6nZspAes4iJST+Pb1cPbW+dldhb7xAg== X-Received: by 2002:a17:906:d261:b0:a86:80b7:4743 with SMTP id a640c23a62f3a-a90d4ffddf4mr353840066b.24.1726869554350; Fri, 20 Sep 2024 14:59:14 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612b3a04sm900617766b.125.2024.09.20.14.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 14:59:13 -0700 (PDT) From: Linus Walleij Date: Fri, 20 Sep 2024 23:59:04 +0200 Subject: [PATCH 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: <20240920-bcm63138-leds-v1-2-c150871324a0@linaro.org> References: <20240920-bcm63138-leds-v1-0-c150871324a0@linaro.org> In-Reply-To: <20240920-bcm63138-leds-v1-0-c150871324a0@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()). Signed-off-by: Linus Walleij Reviewed-by: Florian Fainelli --- 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 20 21:59:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 829943 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 4D9FE1420B6 for ; Fri, 20 Sep 2024 21:59:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726869560; cv=none; b=Pe+t9nn0tBOkJs5Rl7SBZwgzMAtocTxnrPGkD0FWgxyzaa/oIkoNKY9Ij7Xe+hl6k2TLEQKhqcQZge/A0iwKdHWJCMDHwcjy1wjZ28nw/nu/Ihoeza07QUTHbTqowWy1xgoisF5py/5vPcbiXtHMYquvJFayY/vJtAsFOlqh0ZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726869560; c=relaxed/simple; bh=pzwKpebvYVuzFkHtfWxT2dIgxpG/NhoiTFU5g0KtTr8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SM57QUlktvgCF8paYW+rolt+Xqmn0vhhPpJGTKRwDK5BC7hsIDySpxUn7jGj/B3qrE495oTn3YVTxmO8N/7WMNDhJziJ4TQw8jUiiIUvJEWFAcVMjwh9jhAU0FasyeFBxZCAuj5BqOMp0CSSUuVUcR3B0hZaFmgnBMGcgyUXouI= 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=xbxtvfyw; arc=none smtp.client-ip=209.85.128.45 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="xbxtvfyw" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42bb7298bdeso29957395e9.1 for ; Fri, 20 Sep 2024 14:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726869556; x=1727474356; 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=QhUCILeSXAkUcmBh/Q/38AfnCBVEM+/ogGyjiE56sKs=; b=xbxtvfywujr+bqkRMHHKHf+0d5d7Ij8Vg4AQ/0m27pXOkHYRE/11Bowp9GM3L1cATj uPtOF1Hs+kQSjhYlSQMyQslddc2BrlUkdl2fshncZa3wmmG9hBkUkj1zzjOJNBsy6aDG JrGeRDVEo6Ia346ey3IuEH5ehMTkMR4a8bZshbEXIBREg5w0hAkfhF73csTLcFjFH5HN pcgi4bX4mbXWxjgYtCPgzjXsL1+fgUqo816MbCyI8G2QfymQ2ho5dkr013nh+TZeh9Hp b1UmfilHpFuko2u/C/GcLp6YLfOWD00jXUOYgp/lfnWwAimsMCrK3t41+GD2Ft2JKqlF uCjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726869556; x=1727474356; 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=QhUCILeSXAkUcmBh/Q/38AfnCBVEM+/ogGyjiE56sKs=; b=lG4vhv8AIz8bpyTd8KhPfpApKcBVNROJ6wVlGf7G+JqP5SqnUF/CSlLwryXqavae70 YJSY739gmQ6Mq+iqt6En3jufnRuaOMmz60icdpO6p3oUJMhNWiv8MRj2WgX8quxOWBxi S5yMZ29fMpX8Uce00on9J/h12BRY/GpwccSvmQcFXCtTqEVv40w9SeKOBexmGlGGPPTv zQdwDn4bsLFaBANo+j4jX0XTV1nO160y+Tyl1p8QV+urovvidY1AvaY6PASR+ImKg4q9 CXRMV3Yp0Cp8ZGFIK/WmoZlIpZKpVpurOFPkP2xl+BBGIopqoyY98pf9tEDcTBZ0tLv6 MbdQ== X-Gm-Message-State: AOJu0YwR8MLPXiXr3ZrTfd/UuWDx377r6r4Bi3KsHYJLDlBu8mLp8qWi USgkhZij5iC/NVuJNVsICYBEBnd39xj4QUc3sY9hlAo/70CxMiiYIX8U6iIWixg= X-Google-Smtp-Source: AGHT+IEn3IcFD2Fbyv6iaMwKQbdR/rjcEenFHfFt8cMW2+izbedffoWXjkJwz6Z8qL+HOX996ORtHw== X-Received: by 2002:a5d:452e:0:b0:374:c847:867 with SMTP id ffacd0b85a97d-37a42367b0fmr3322120f8f.47.1726869556517; Fri, 20 Sep 2024 14:59:16 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612b3a04sm900617766b.125.2024.09.20.14.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 14:59:15 -0700 (PDT) From: Linus Walleij Date: Fri, 20 Sep 2024 23:59:05 +0200 Subject: [PATCH 3/4] leds: bcm63128: 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: <20240920-bcm63138-leds-v1-3-c150871324a0@linaro.org> References: <20240920-bcm63138-leds-v1-0-c150871324a0@linaro.org> In-Reply-To: <20240920-bcm63138-leds-v1-0-c150871324a0@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..bf170a5bb12a 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(32 - 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 20 21:59:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 830080 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 B12A717A5BD for ; Fri, 20 Sep 2024 21:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726869562; cv=none; b=Pe1Upe1HOOjuv06OMNiTfr51veCJUYeMRV+G3c+A0YRjKoZwYPt82saAaZ1EfjLEYlSrk7UhcJrafteu7RyCZ4feYhspN8CrMxMJAPuumVlw1saCkP7PM4+I0cOxc9prEcuXh8wpYADAL5r9Wqo2e2w4WqNRPljzFsVltcZsAm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726869562; c=relaxed/simple; bh=l8UrMMl+XiCitGcSyZEyUnWFB/kx9++xvkTMEW+7fac=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c3Nme7zPiwpTXXAgLk73ilIrEO5ZjI8xuKmQo3yjBkpg5dICxE1//Mf08UTStEmq/qbmtL7AY5PnW/Ysa1et4a/qghGiq1u+OeWc2AmDbHqzb44ZYjUvaoo0TSgQ3lPLHjbxmv0tOL7UQTFThl3qWN2HXkYn/C3YSBD5KqPVv1I= 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=QE26CvWc; arc=none smtp.client-ip=209.85.208.179 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="QE26CvWc" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2f761461150so32854271fa.0 for ; Fri, 20 Sep 2024 14:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726869559; x=1727474359; 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=VzPsbxlIe6IRbEbm5DY1ymWkQnjwtpeBnU1CWieHtFE=; b=QE26CvWcOHF7iWJOX+Qm8+BBELj/UA4WsbCS6rNmwOOaKuAazbtWYn4G6EcqaEdeLk 3Tgtzne3jFE3qbUYMxnlZGSk8EtrJEjV61Wr8TUNccgU63k3ha4URUtUJNR3bB2SiYp0 34DV/mB+TLOdsI+V4wGNMUBCGEPwCM/QEDlPsgTVpUo0Jz1tyRuzjl6ewtvZZAFjQrmD txUWs3/GRZ6+CkmJh6Mn29dCTcPAaGZmakS2EcyaYeZ4kcX4UCusz8xYvNmK3lVmhyj3 5ny1rsYP5b6IDiMLy1cpIOxnSkSeErb89t7IVjPAzlqQqH1kTfHEjuAoRqorRHbFchYU ip/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726869559; x=1727474359; 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=VzPsbxlIe6IRbEbm5DY1ymWkQnjwtpeBnU1CWieHtFE=; b=IRHRbOr5LK4JLV2kcNi4UdxtGMngCjZw7D/dlpcuy6/LPLzYVGMXWiyNVx6WRZTI5P yzZoQFMIFpQcpCja/sxjzrAH3FjqbLfyzrBqq27HYpk74nAQ3nB0b5/HTocPVG2KJWCs 2DpNZajzrx0U4YGwjgcYjlptdPD6zXnG4SvWz5eWKa61i45h85yymZTtylsto42pxjXP XlLnTX/S64CDBiAZ9j3AMBJ34O74QY3zumEr5FUHY5v8QZF7KZGKsfN8lQGXj3N7m0Jl X/iRxS1Pk/+kM9e54wTFg2NYyBfUWiGYBvekwbaJOJ72jsfVONenJ8ot/Kwvp6qM6Tti kinA== X-Gm-Message-State: AOJu0YyxmNS0F4SbNEdaQJGmuH9X1lEOo81VPP3XR2nU+hv/Ks7yaNlD hAVP7Ww9i+WQK0uSL+DUZUrY1kdj3mGoJy3R89HVdApDMn49QGAnfbfvbbvLUao2GQgy2PzIJWL f X-Google-Smtp-Source: AGHT+IH6SbCQEmEqRaiGipifz6PXrREBY/Ep5fUadn1XeA415QbsR2O46Rxq9QULzrKck/HpYpyc5w== X-Received: by 2002:a2e:a546:0:b0:2f0:1a95:7106 with SMTP id 38308e7fff4ca-2f7cb36edaamr40852941fa.39.1726869558757; Fri, 20 Sep 2024 14:59:18 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90612b3a04sm900617766b.125.2024.09.20.14.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 14:59:17 -0700 (PDT) From: Linus Walleij Date: Fri, 20 Sep 2024 23:59:06 +0200 Subject: [PATCH 4/4] leds: bcm63128: 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: <20240920-bcm63138-leds-v1-4-c150871324a0@linaro.org> References: <20240920-bcm63138-leds-v1-0-c150871324a0@linaro.org> In-Reply-To: <20240920-bcm63138-leds-v1-0-c150871324a0@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 Powert 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 bf170a5bb12a..7d9d970b2082 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