drivers: led_strip: ws2812_rpi_pico_pio: Change output-pin
to gpios
For sharing pin definition property with `worldsemi,ws2812-gpio`, rename `output-pin` to `gpios`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
This commit is contained in:
parent
0702f0eb45
commit
0f458c9564
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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), \
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -47,18 +47,16 @@ 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
|
||||
for use by PIO.
|
||||
for use by PIO. This property only uses the GPIO pin number and ignores flags.
|
||||
|
||||
frequency:
|
||||
type: int
|
||||
|
|
15
dts/bindings/led_strip/ws2812-gpio.yaml
Normal file
15
dts/bindings/led_strip/ws2812-gpio.yaml
Normal file
|
@ -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.
|
Loading…
Reference in a new issue