Skip to content

Commit 4a8f2b3

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 <[email protected]>
1 parent d6d83ad commit 4a8f2b3

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
@@ -342,7 +342,8 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
342342
waveshare-can-fd-hat-mode-a.dtbo \
343343
waveshare-can-fd-hat-mode-b.dtbo \
344344
wittypi.dtbo \
345-
wm8960-soundcard.dtbo
345+
wm8960-soundcard.dtbo \
346+
ws2812-pio.dtbo
346347

347348
targets += dtbs dtbs_install
348349
targets += $(dtbo-y)

arch/arm/boot/dts/overlays/README

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

56015601

5602+
Name: ws2812-pio
5603+
Info: Configures a GPIO pin to drive a string of WS2812 LEDS using pio. It
5604+
can be enabled on any RP1 GPIO in bank 0 (0-27). Up to 4 are supported,
5605+
assuming nothing else is using PIO. Pi 5 only.
5606+
Load: dtoverlay=ws2812-pio,<param>=<val>
5607+
Params: brightness Set the initial brightness for the LEDs. The
5608+
brightness can be changed at runtime by writing
5609+
a single byte to offset 0 of the device. Note
5610+
that brightness is a multiplier for the pixel
5611+
values, and only white pixels can reach the
5612+
maximum visible brightness. (range 0-255,
5613+
default 255)
5614+
dev_name The name for the /dev/ device entry. Note that
5615+
if the name includes '%d' it will be replaced
5616+
by the instance number. (default 'leds%d')
5617+
gpio Output GPIO (0-27, default 4)
5618+
num_leds Number of LEDs (default 60)
5619+
rgbw 'rgbw=on' (or 'rgbw') indicates that each pixel
5620+
includes a white LED as well as the usual red,
5621+
green and blue. (default 'off')
5622+
5623+
56025624
Troubleshooting
56035625
===============
56045626

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)