From patchwork Thu Oct 10 14:10: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: 834364 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 D53C61BDA99 for ; Thu, 10 Oct 2024 14:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569460; cv=none; b=PhXHMOhrOFYXeAPZPG7JFt3p9M9z4miiFS4AvxEuxg33ZddXdn66KWoAY2Qu52y1FzHYxg4hQJzszu0/ikKbWbQ7/qpqUUllAezpu0LMzsRfc1zTXIrvwtY2KW1bno0dhxb7iVnNT5cEvyLfh1mgFC5wi+AKG7UHntMH32RPwmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569460; c=relaxed/simple; bh=0Qglc/xTIffv1fsSKk0eokjPIP1tzyiC6cSA5ONdmlo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ICmzG6xQC4lBubVYXaWHIiFJRFXNud+qOaNQTGIIi0zXqDxK7XPPkFb4hrhwNoI3n6cmLkwbuKr0Z4mTHkCLvXO1u0iG8UycKQVXBMMG4/5JK0JP7m0pVuUFQVwZTLhMcYvmrmvYEm+xqkNv0vCBQxbZHyhJeK/5aQ2BLoUoiA0= 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=jLdCEtHp; arc=none smtp.client-ip=209.85.218.47 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="jLdCEtHp" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a9951fba3b4so154385566b.1 for ; Thu, 10 Oct 2024 07:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728569457; x=1729174257; 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=IW8XCdBGRYIhZReATpdQK1C+vM89LTQJraH135VfcEI=; b=jLdCEtHpWvr2vIgWSFGobfykvXRRT87ZF3lfvdcGlsWp/DUPU1J6TwTpO4UKU5/fyk aDjhc4XhnbwK2Fny9jv5xLsKH3iJ7a8vOugnMkcU0Bjuw6SuRbcWIX2uF4ArSClJdiT1 oD9OEn+g1K04WTTWZnDsVHJbUsf9Swy+yhF/ne4Q/+CxaNe8RBYCUCqNVxizQjMRJHhX 5A0zuPV15KwbfdFeZ1ICjNeipLG3skczN8og/viw5frwq7/ppuomdubJTVA5t9PDZuqe Sn2CoJbm0LX3TkcczWbSph1I/Ev+dA+5Ts1Fp7e5FPUPx1lfPRq9byb1UBFREfAi2o2E g+jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728569457; x=1729174257; 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=IW8XCdBGRYIhZReATpdQK1C+vM89LTQJraH135VfcEI=; b=l6eWgsMa2GqQzmFIPz9OfCu9GeZO8ogyUl+xn4l2K7WjOd/4RbTwzH79sUJBgXhriL 6uvQkBlqOCTQDpkQ9O8kdq9WgvTemQ35l+l+Qp6o1IIC58HK1AN3DSX0zzxwiAPux60u 2Af2XZ+NfP2pAu8TW/Vf9HaO/Iz45zgngIxjRnCAU7gIMijh4zfjh/wNwXDyTj+3FE2v zfAI32IAyX3suCZJoQ0RIH9Toc1EVp/5ooGloSROT/vo7IEC6kyqZwDMgxhPe8Taqg4H QYDVwloeKIL5bv7PF/cLj3k+FxD1/wcByX1pWGIYQuab26u7KaOnMHpF+uggPLpNz3zQ TD6w== X-Gm-Message-State: AOJu0Yybhrgijt5dMaZDtWA1Vgpr+9weJyhXO3/7GXLT2XmhPKVa/Jnq zoXRFCs0ZzxoMC7mz9yDFh3AEQhWtDyie7+SRnne9SuRzeCea2OjhMleflnQIrg= X-Google-Smtp-Source: AGHT+IF9T6MbyVFvtNK4bdZhjMeVz375HJKPnDEOmxQLJ4N6tuKly16JWaZNHR28YKCpHdpsPQ+hUw== X-Received: by 2002:a17:907:c899:b0:a99:56e1:bd30 with SMTP id a640c23a62f3a-a998d313b3amr552425666b.42.1728569457039; Thu, 10 Oct 2024 07:10:57 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7ec5704sm94540866b.23.2024.10.10.07.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 07:10:55 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 16:10:50 +0200 Subject: [PATCH v4 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: <20241010-bcm63138-leds-v4-1-cdb80780a555@linaro.org> References: <20241010-bcm63138-leds-v4-0-cdb80780a555@linaro.org> In-Reply-To: <20241010-bcm63138-leds-v4-0-cdb80780a555@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 Reviewed-by: Rob Herring (Arm) --- ChangeLog v2->v3: - Mention that HW defaults will be used if the shift register property is missing. 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml index bb20394fca5c..62326507c1aa 100644 --- a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml +++ b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml @@ -41,6 +41,16 @@ 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. If left unspecified, the hardware boot-time default is used. + patternProperties: "^led@[a-f0-9]+$": type: object @@ -71,6 +81,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 Thu Oct 10 14:10:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 835302 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 01E2A1CB324 for ; Thu, 10 Oct 2024 14:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569462; cv=none; b=OwaYQEnSwSJ43RG81zmL7axuBhBpe2kOIV+ESMqSGa3stiJHS6dTKaadI+U3sgcurmmdeL2+Ddo05coAgF32snDiw3X36iPCMemFrtVaQSLrHDbAEMpxLVPVxiXgR+UsEvv4o1+4ofTv4tdK9VTdRA5kwuqMNhYsT+WOU788430= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569462; c=relaxed/simple; bh=gvBNRxgBPZ2zeZFI0slr0ZK/bibGW/1MvVv3P+uNb5g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hz2ZXQj/ADJRU1YIGI8ysGtKXRU2uY+deMa4HJKALUkn5RSpEsd2HqgbQm3v3jpcM7PHKmmChhaNUl0oy89X6UTc273G4Gir+Vny8YySP4F4ZklsWk7yYEgJ41inatI/shfpeFnnoO6rNukr8rNmUL4ngr0GhWeq7Ux5FP9IEGI= 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=Yb856gu4; arc=none smtp.client-ip=209.85.218.46 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="Yb856gu4" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a999521d0c3so164660066b.1 for ; Thu, 10 Oct 2024 07:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728569459; x=1729174259; 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=Z7sMROkRKGoFLIFPCxBzcqqWuegoZL694cLilxCXEAc=; b=Yb856gu4ZYUWe+KIhYVGbfzm8taZbaUSjxjckHrhvds8swO2sND9nCYyPbYePnMwis Ifs9oTCvoxoHOSLMq0msO3BA+KwvyhY0mhQK6lrD9yZASCsZyYhIVaOlNKX5GwUiIhRY we5jMey6TOqDBnopdHPefomtxwxQNnGTowpmaNCqyueAjKm6oYTK9nAkMg3SUE3Hzm3k 0Rie68VkhzKZRsUnDXYZBgRZ58eu9WMMRgwsJ8Nw/ZRFzKnLmp1DwJeRbhzmfFE9Cg65 wf/VCUCNTKu0Ki645NW8yy0BGSdus0Un6PL3cS26QjXYPNo8zooJxmcxVTLroIP8U4zt efgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728569459; x=1729174259; 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=Z7sMROkRKGoFLIFPCxBzcqqWuegoZL694cLilxCXEAc=; b=UZM0V7MIV1AxEFjTg15vKuzr/KOHrbguvrV2WnVtIjepMrY8WlYVKiaRhtMRzY4TYE qu+cdQhcYfhv50xaEODBT/2xoBFZnS8YycI6W2/jzdj50mJJOsXNfkG5p7LtWNKFLJ+U woLxG+rwGWqOZ5+O912VCdAVx4ZWc2gSCl9IYQAfvjnM4hc32BL36PxKvceIiy6iFc1V YGJR4pailHSUDdHH46iLFoSs1xAzDl1tlALSPq1Y5k5DaUv2bDiE61Tot+J6BZiK3UnB xBqtZ+DXA1C4rYceGGx4ircwvlCrjhqPXU6lmY0lamjVbyyWb3IdMUPtyEQJ/qvm9I+p BrrA== X-Gm-Message-State: AOJu0YxY36P8sknigNsVCxe4zF3TNGbKkl9YLDyTmS+A56rBfeBl1GWa /XmqIS6rvbRHq5T0Jf0UN7e8YuJcL328pr9hWYm7QNskT+ZuxRzqfUNDg1KWZKQ= X-Google-Smtp-Source: AGHT+IEuuUbomch6k13XEw7+i2ujQMHPYDCYT4xRgwBH/IsoA7Ire1rPyJAiOKaWwFy0P328wZMOVA== X-Received: by 2002:a17:907:1ca5:b0:a99:40e3:23e8 with SMTP id a640c23a62f3a-a998d32d757mr457102466b.51.1728569459248; Thu, 10 Oct 2024 07:10:59 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7ec5704sm94540866b.23.2024.10.10.07.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 07:10:57 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 16:10:51 +0200 Subject: [PATCH v4 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: <20241010-bcm63138-leds-v4-2-cdb80780a555@linaro.org> References: <20241010-bcm63138-leds-v4-0-cdb80780a555@linaro.org> In-Reply-To: <20241010-bcm63138-leds-v4-0-cdb80780a555@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 Thu Oct 10 14:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 834363 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 B1DF91CB31B for ; Thu, 10 Oct 2024 14:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569465; cv=none; b=PqNCFHdVCSikZgPhM3QIZdYJEb3v8absTRQh1yobmrG4eNrPI26oelVoizOhuUh1GNjhjUqmWCkWq0pGtZwQTsIlZVxV/OFHz/9sqyTcSqqansS2fFpZATOy6a9lbyeo7dLY7K0cT1QQvNYi+Kqh+N3EcxfXMb+gFiEWabDHnlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569465; c=relaxed/simple; bh=TTK1NqTwKaAcG1R8Vv5dIM5PCnv14GB/InNEdUbcv4M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TBT8dttrZ6nHXDtmyrf2DMINY6TEN1KQ/J+EeNhxXmKQEyrDUEAQ9vQxzXuo9ic1Z5rPXrqZSkG9sjbUtOE+3kacesP0v76uAFHJiMIxlUYE5GTepFF/tXBjwREAeBWjM7afhskHlAW0q7QSMeg+GbtqISQ7NGpaZmaVXs+5tQ4= 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=WfPxYS8x; arc=none smtp.client-ip=209.85.167.53 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="WfPxYS8x" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-5398f3be400so1108113e87.0 for ; Thu, 10 Oct 2024 07:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728569462; x=1729174262; 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=Q198k3laC4sYOI7HaGU3RlY+asnk7UU8bvlf4eyLYBM=; b=WfPxYS8xrJ3J4+S9SiP12hZ8wtOSx6VGQBsrSR3MI5c2USr/A33aWjX8fOWHLCxcbM YVwRT/ysYAfUA5P8pcbjA1oTUVByS/FxQ7C7k2fdkzrHQ8iFSlxi17MC6xYc73Id2kOR +DUx5qXnk7t9FxLyre6gRK0Oo6OQsunmW4U906Is7BJXYMx94cquFlUnVlwOPA2aIDKP 8a7E8UJkeudb4jm7qKylLGEInviuy3GYajwsS4rq6f1C5t05WkWSbbF9XRdJU7S3PQy4 npzBuNm1CRxjeBaYs2bKLDB2fK1htacan8Uv3ivwukwCSlS7PxPCgcu1NaMvPMyLE0fZ BZjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728569462; x=1729174262; 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=Q198k3laC4sYOI7HaGU3RlY+asnk7UU8bvlf4eyLYBM=; b=jbm0NESsqoyozG5B64e0a6DyJnG89X0YiFUPsj0NlGtMfZqC1+JT8t6OR7YU1yA55k VUEXZyLyJej5HvDlw8H75NwOBY1xjYE1NGj/PV659h4erYcLaW6GIFjZMs45cPcrrk4X Xl9h2ZEXYaFQFdC6guxESwvMRLGIDLldDMhGjb5d4qDipPVWtaltSLZxGIfXfWSks0EY fO209gduio+6/s3go9mWgNHsknwViJ6UNXuDc0kDVvwFON24ht2ECUA3HWu3DFDScYz0 4mLqfZkfZlLGH14dDdvzal4Vq+P2I1M0Hxs3Trl1+XgL5PF39neukFMraKzKAqTcKSYj ABCw== X-Gm-Message-State: AOJu0YyQ0afdyqj4ZuhL6uxu68bwdW+ZH2gg9ndR8TBheHR7iUNucl05 nzS+ZO1DYsuMghD8t/d4uquFLma7KrMmc/UHLhBqdhl2NAP23ufdSckiuI+t2e7j1lpiUopxCfd e X-Google-Smtp-Source: AGHT+IEHbvFN/0c3gTJeqcUxsxwpXpbvXc0bdD+m1MfpXj+Vxw5Z2jBW3d/SwwatThHPBe74AL3ahg== X-Received: by 2002:a05:6512:12c8:b0:52c:99c9:bef6 with SMTP id 2adb3069b0e04-539c488a4eemr4220783e87.7.1728569461791; Thu, 10 Oct 2024 07:11:01 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7ec5704sm94540866b.23.2024.10.10.07.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 07:11:00 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 16:10:52 +0200 Subject: [PATCH v4 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: <20241010-bcm63138-leds-v4-3-cdb80780a555@linaro.org> References: <20241010-bcm63138-leds-v4-0-cdb80780a555@linaro.org> In-Reply-To: <20241010-bcm63138-leds-v4-0-cdb80780a555@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 Reviewed-by: Florian Fainelli --- 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 Thu Oct 10 14:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 835301 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 EC2E81CB31B for ; Thu, 10 Oct 2024 14:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569467; cv=none; b=LB8mao0MjEZYWYzOgAyd46VrUPjYhb9hS1M4STFxj6XKd3U+6NzQTkRoZK+aHIaCgdTtIh44V8vIm/esxdKPVqST951HhnnMBocEw7UA0BEclp4w2BBwd+7xep5i872g12tQ0UHlVYEghq95R0/p74kFd1FXiFNXMYI7wzq70CI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728569467; c=relaxed/simple; bh=WusKKE0s/C250H6Ic+WHqBCTzkX5UUtA/Dz8FhleAm0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nd4XFMvmFGS1sRtaKkzkkzzAzcQjuThTJTl2tEGQ0DVFzfupmJ05JsDavENgI1aD6IR9xFxQGy6f4KV/T20oca/sjjIWnqRsCr5tXrcPDokHRYPIzkpLjTHCPEq/VzEohwUfEsTTefEtrmRjfcn2GnfxWfqxq1VCn/76k/6j4gE= 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=ns7e+oNM; arc=none smtp.client-ip=209.85.208.42 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="ns7e+oNM" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5c91d0eadbfso1304780a12.0 for ; Thu, 10 Oct 2024 07:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728569464; x=1729174264; 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=7gIA9KyLtGspfj/GVuihkBjQsPxtJlRt1YBA5ISw3Cw=; b=ns7e+oNMTc56qi6ENkdhMoLU7Bp1glGbdBsQixQ3bs4xFaiOjxNii8RPQfIJm261tB nEFV9xMSbq91s0fM/9fCAYlUdyE5MWeYy78NwU9zQlae1w391cAlUkep8I2uHc9D6F0s 9Bur8F4SaN1grhdXml5Rb9R/gcrcQeQcduNOiEyGXK6Ai0HhSmirkwWhJgTCLRKuPDuk OzaE/TFkdabRDONiiDO81eXGzWr2vLQea23lMTF7HqGBZ5/oe3fXjtCPVj7aN2/1Ua9J 1c9gOavRnAm2sYTEjApsr/nPfC5h2sojCerF+hIAbllKiazNwGkBZp5tX3I4xOWWT/C1 x8VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728569464; x=1729174264; 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=7gIA9KyLtGspfj/GVuihkBjQsPxtJlRt1YBA5ISw3Cw=; b=wjm8qHN3ZRVjn7n9kcY3UOjZHYkUSUjGwgnTIinhU/YWgbFLxDiUHBEaw3u9fktb0L Y7hcFT3BVyWjQrJkNeJxj5wxRewxgqMf2r2Do2EVxJdkUKqzX2c1bESI87fTndQ8Y6Sy QOKAp/oVNHFndzY9UIwJ9ItdwWgFujjb0/vkyyhBqxq403c8WEr/5e4ZPD0o6nD9upI2 ckQUqOIVxvB5aRpqPEWeWULcXvhqCuV/A4svTXIUb7+VXrzFA6AcIqpI2trg0PjSumME 7yHxuyUkFGC7o17h40eKTryVNukvsjY7pNQQcjCbhdbnCRvJtcKdZaJTnPVZGEdEf7rS ZQlw== X-Gm-Message-State: AOJu0Yzf6ECdhv5//gmv5TypxK5u39g1AWT7kwvwgnsIm2U2jBHv22As qmzkdQlRh/z11Lq5WzgFnIv0pTZus+wRSw+7dqUBW4cmZyGm4S5dF9xyufOO9CU= X-Google-Smtp-Source: AGHT+IGDCy3FxI2wv1M4R8UM4BESWGps4XkzOFyCV8pwYF+qefWgWfkdQDDKuAV5rg1LwB5szYVh9A== X-Received: by 2002:a17:907:c05:b0:a99:7bc0:bca9 with SMTP id a640c23a62f3a-a998d11f6bemr556191866b.3.1728569464224; Thu, 10 Oct 2024 07:11:04 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7ec5704sm94540866b.23.2024.10.10.07.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 07:11:02 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 16:10:53 +0200 Subject: [PATCH v4 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: <20241010-bcm63138-leds-v4-4-cdb80780a555@linaro.org> References: <20241010-bcm63138-leds-v4-0-cdb80780a555@linaro.org> In-Reply-To: <20241010-bcm63138-leds-v4-0-cdb80780a555@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 --- ChangeLog v3->v4: - Add define for BCM63138_GLB_CTRL_SERIAL_LED_CLK_POL - Rename the BCM63138_POWER_LUT to BCM63138_POWER_LUT_BASE0 --- drivers/leds/blink/leds-bcm63138.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/leds/blink/leds-bcm63138.c b/drivers/leds/blink/leds-bcm63138.c index 9fe1af156c80..ef2e511438cc 100644 --- a/drivers/leds/blink/leds-bcm63138.c +++ b/drivers/leds/blink/leds-bcm63138.c @@ -21,8 +21,10 @@ #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_CLK_POL BIT(2) +#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 +37,7 @@ #define BCM63138_BRIGHT_CTRL3 0x28 #define BCM63138_BRIGHT_CTRL4 0x2c #define BCM63138_POWER_LED_CFG 0x30 +#define BCM63138_POWER_LUT_BASE0 0x34 /* -> b0 */ #define BCM63138_HW_POLARITY 0xb4 #define BCM63138_SW_DATA 0xb8 #define BCM63138_SW_POLARITY 0xbc