Skip to content

Commit 1c2101d

Browse files
committed
overlays: Add ws2812-pio overlay
Add an overlay to enable a WS2812 LED driver on a given GPIO. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent 6f39291 commit 1c2101d

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

arch/arm/boot/dts/overlays/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
344344
waveshare-can-fd-hat-mode-a.dtbo \
345345
waveshare-can-fd-hat-mode-b.dtbo \
346346
wittypi.dtbo \
347-
wm8960-soundcard.dtbo
347+
wm8960-soundcard.dtbo \
348+
ws2812-pio.dtbo
348349

349350
targets += dtbs dtbs_install
350351
targets += $(dtbo-y)

arch/arm/boot/dts/overlays/README

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5641,6 +5641,28 @@ Params: alsaname Changes the card name in ALSA
56415641
compatible Changes the codec compatibility
56425642

56435643

5644+
Name: ws2812-pio
5645+
Info: Configures a GPIO pin to drive a string of WS2812 LEDS using pio. It
5646+
can be enabled on any RP1 GPIO in bank 0 (0-27). Up to 4 are supported,
5647+
assuming nothing else is using PIO. Pi 5 only.
5648+
Load: dtoverlay=ws2812-pio,<param>=<val>
5649+
Params: brightness Set the initial brightness for the LEDs. The
5650+
brightness can be changed at runtime by writing
5651+
a single byte to offset 0 of the device. Note
5652+
that brightness is a multiplier for the pixel
5653+
values, and only white pixels can reach the
5654+
maximum visible brightness. (range 0-255,
5655+
default 255)
5656+
dev_name The name for the /dev/ device entry. Note that
5657+
if the name includes '%d' it will be replaced
5658+
by the instance number. (default 'leds%d')
5659+
gpio Output GPIO (0-27, default 4)
5660+
num_leds Number of LEDs (default 60)
5661+
rgbw 'rgbw=on' (or 'rgbw') indicates that each pixel
5662+
includes a white LED as well as the usual red,
5663+
green and blue. (default 'off')
5664+
5665+
56445666
Troubleshooting
56455667
===============
56465668

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Device tree overlay for RP1 PIO WS2812 driver.
3+
/dts-v1/;
4+
/plugin/;
5+
6+
/ {
7+
compatible = "brcm,bcm2712";
8+
9+
fragment@0 {
10+
target = <&gpio>;
11+
__overlay__ {
12+
ws2812_pio_pins: ws2812_pio_pins@4 {
13+
brcm,pins = <4>; /* gpio 4 */
14+
function = "pio";
15+
bias-disable;
16+
};
17+
};
18+
};
19+
20+
fragment@1 {
21+
target-path = "/";
22+
__overlay__ {
23+
ws2812_pio: ws2812_pio@4 {
24+
compatible = "raspberrypi,ws2812-pio-rp1";
25+
pinctrl-names = "default";
26+
pinctrl-0 = <&ws2812_pio_pins>;
27+
dev-name = "leds%d";
28+
leds-gpios = <&gpio 4 0>;
29+
rpi,num-leds = <60>;
30+
rpi,brightness = <255>;
31+
};
32+
};
33+
};
34+
35+
__overrides__ {
36+
brightness = <&ws2812_pio>, "rpi,brightness:0";
37+
dev_name = <&ws2812_pio>, "dev-name";
38+
gpio = <&ws2812_pio>,"leds-gpios:4",
39+
<&ws2812_pio_pins>,"brcm,pins:0",
40+
/* modify reg values to allow multiple instantiation */
41+
<&ws2812_pio>,"reg:0",
42+
<&ws2812_pio_pins>,"reg:0";
43+
num_leds = <&ws2812_pio>, "rpi,num-leds:0";
44+
rgbw = <&ws2812_pio>, "rpi,rgbw?";
45+
};
46+
};

0 commit comments

Comments
 (0)