diff --git a/boards/adafruit/kb2040/adafruit_kb2040.dts b/boards/adafruit/kb2040/adafruit_kb2040.dts index c17700aa8f..45ff45595d 100644 --- a/boards/adafruit/kb2040/adafruit_kb2040.dts +++ b/boards/adafruit/kb2040/adafruit_kb2040.dts @@ -108,7 +108,7 @@ ws2812: ws2812 { status = "okay"; - output-pin = <17>; + gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; chain-length = <1>; color-mapping = ; + gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; chain-length = <1>; color-mapping = #include #include #include @@ -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), \ diff --git a/dts/bindings/led_strip/worldsemi,ws2812-gpio.yaml b/dts/bindings/led_strip/worldsemi,ws2812-gpio.yaml index c69a63043b..a759d5f6fe 100644 --- a/dts/bindings/led_strip/worldsemi,ws2812-gpio.yaml +++ b/dts/bindings/led_strip/worldsemi,ws2812-gpio.yaml @@ -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] diff --git a/dts/bindings/led_strip/worldsemi,ws2812-rpi_pico-pio.yaml b/dts/bindings/led_strip/worldsemi,ws2812-rpi_pico-pio.yaml index d5d41ed38e..d0c8d38e63 100644 --- a/dts/bindings/led_strip/worldsemi,ws2812-rpi_pico-pio.yaml +++ b/dts/bindings/led_strip/worldsemi,ws2812-rpi_pico-pio.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 diff --git a/dts/bindings/led_strip/ws2812-gpio.yaml b/dts/bindings/led_strip/ws2812-gpio.yaml new file mode 100644 index 0000000000..abfba22ddf --- /dev/null +++ b/dts/bindings/led_strip/ws2812-gpio.yaml @@ -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.