Skip to content

Commit 5f312fd

Browse files
Linus Walleijlag-linaro
authored andcommitted
leds: bcm63138: Handle shift register config
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 <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 6157407 commit 5f312fd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/leds/blink/leds-bcm63138.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/*
33
* Copyright (C) 2021 Rafał Miłecki <[email protected]>
44
*/
5+
#include <linux/bits.h>
56
#include <linux/cleanup.h>
67
#include <linux/delay.h>
78
#include <linux/io.h>
@@ -254,6 +255,7 @@ static int bcm63138_leds_probe(struct platform_device *pdev)
254255
struct device_node *np = dev_of_node(&pdev->dev);
255256
struct device *dev = &pdev->dev;
256257
struct bcm63138_leds *leds;
258+
u32 shift_bits;
257259

258260
leds = devm_kzalloc(dev, sizeof(*leds), GFP_KERNEL);
259261
if (!leds)
@@ -267,6 +269,12 @@ static int bcm63138_leds_probe(struct platform_device *pdev)
267269

268270
spin_lock_init(&leds->lock);
269271

272+
/* If this property is not present, we use boot defaults */
273+
if (!of_property_read_u32(np, "brcm,serial-shift-bits", &shift_bits)) {
274+
bcm63138_leds_write(leds, BCM63138_SERIAL_LED_SHIFT_SEL,
275+
GENMASK(shift_bits - 1, 0));
276+
}
277+
270278
bcm63138_leds_write(leds, BCM63138_GLB_CTRL,
271279
BCM63138_GLB_CTRL_SERIAL_LED_DATA_PPOL |
272280
BCM63138_GLB_CTRL_SERIAL_LED_EN_POL);

0 commit comments

Comments
 (0)