Skip to content

Commit

Permalink
drivers: led_strip: ws2812_rpi_pico_pio: Change output-pin to gpios
Browse files Browse the repository at this point in the history
For sharing pin definition property with `worldsemi,ws2812-gpio`,
rename `output-pin` to `gpios`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
  • Loading branch information
soburi committed Feb 28, 2024
1 parent 583a8f7 commit a981b93
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion boards/arm/adafruit_kb2040/adafruit_kb2040.dts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

ws2812: ws2812 {
status = "okay";
output-pin = <17>;
gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/adafruit_qt_py_rp2040/adafruit_qt_py_rp2040.dts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

ws2812: ws2812 {
status = "okay";
output-pin = <12>;
gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
Expand Down
9 changes: 5 additions & 4 deletions drivers/led_strip/ws2812_rpi_pico_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/led_strip.h>
#include <zephyr/drivers/misc/pio_rpi_pico/pio_rpi_pico.h>
Expand All @@ -21,7 +22,7 @@ struct ws2812_led_strip_data {

struct ws2812_led_strip_config {
const struct device *piodev;
uint32_t output_pin;
const uint8_t gpio_pin;
uint8_t num_colors;
uint32_t frequency;
const uint8_t *const color_mapping;
Expand Down Expand Up @@ -52,11 +53,11 @@ static int ws2812_led_strip_sm_init(const struct device *dev)
}

sm_config_set_sideset(&sm_config, 1, false, false);
sm_config_set_sideset_pins(&sm_config, config->output_pin);
sm_config_set_sideset_pins(&sm_config, config->gpio_pin);
sm_config_set_out_shift(&sm_config, false, true, (config->num_colors == 4 ? 32 : 24));
sm_config_set_fifo_join(&sm_config, PIO_FIFO_JOIN_TX);
sm_config_set_clkdiv(&sm_config, clkdiv);
pio_sm_set_consecutive_pindirs(pio, sm, config->output_pin, 1, true);
pio_sm_set_consecutive_pindirs(pio, sm, config->gpio_pin, 1, true);
pio_sm_init(pio, sm, -1, &sm_config);
pio_sm_set_enabled(pio, sm, true);

Expand Down Expand Up @@ -187,7 +188,7 @@ static int ws2812_rpi_pico_pio_init(const struct device *dev)
\
static const struct ws2812_led_strip_config ws2812_led_strip_##node##_config = { \
.piodev = DEVICE_DT_GET(DT_PARENT(DT_PARENT(node))), \
.output_pin = DT_PROP(node, output_pin), \
.gpio_pin = DT_GPIO_PIN_BY_IDX(node, gpios, 0), \
.num_colors = DT_PROP_LEN(node, color_mapping), \
.color_mapping = ws2812_led_strip_##node##_color_mapping, \
.reset_delay = DT_PROP(node, reset_delay), \
Expand Down
10 changes: 1 addition & 9 deletions dts/bindings/led_strip/worldsemi,ws2812-gpio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,4 @@ description: |
compatible: "worldsemi,ws2812-gpio"

include: [base.yaml, ws2812.yaml]

properties:
gpios:
type: phandle-array
required: true
description: |
GPIO phandle and specifier for the pin connected to the daisy
chain's input pin. Exactly one pin should be given.
include: [base.yaml, ws2812-gpio.yaml]
8 changes: 3 additions & 5 deletions dts/bindings/led_strip/worldsemi,ws2812-rpi_pico-pio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ child-binding:
Worldsemi WS2812 or compatible LED strip driver based on RaspberryPi Pico's PIO
The LED strip node can put up to 4 instances under a single PIO node.
include: ws2812.yaml
include: ws2812-gpio.yaml

properties:
output-pin:
type: int
required: true
gpios:
description: |
Select the output pin.
Inherited from ws2812-gpio.yaml.
Note: This driver does not configure the output pin.
You need to configure the pin with pinctrl that is in the parent node configuration
Expand Down
15 changes: 15 additions & 0 deletions dts/bindings/led_strip/ws2812-gpio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2024, TOKITA Hiroshi
# SPDX-License-Identifier: Apache-2.0

include: ws2812.yaml

description: |
Common definition GPIO based WS2812 node
properties:
gpios:
type: phandle-array
required: true
description: |
GPIO phandle and specifier for the pin connected to the
led-strip. Exactly one pin should be given.

0 comments on commit a981b93

Please sign in to comment.