Files
zephyr_llcc68_driver/drivers/llcc68/llcc68_raw.c
T
crosstyan d8db9e1eb0 fix(llcc68): move SPI CS delay to devicetree
Zephyr deprecates passing the chip-select delay as the variadic delay argument to SPI_DT_SPEC_INST_GET. Remove that deprecated macro argument from the raw LLCC68 device initializer.

Add spi-cs-setup-delay-ns and spi-cs-hold-delay-ns defaults to the custom LLCC68 devicetree binding. Both defaults are 100000 ns, preserving the previous 100 us delay behavior while using the current Zephyr SPI devicetree properties.

Verified with cmake -S . -B build and cmake --build build from the parent application.
2026-05-25 10:12:53 +08:00

69 lines
3.2 KiB
C

#include "llcc68_raw.h"
#include <errno.h>
#include <zephyr/sys/util.h>
#define DT_DRV_COMPAT semtech_llcc68_weihua
static void dio1_irq_trampoline(const struct device *port, struct gpio_callback *cb, uint32_t pins) {
ARG_UNUSED(port);
struct llcc68_data *data = CONTAINER_OF(cb, struct llcc68_data, dio1_irq_callback);
const struct llcc68_config *config = data->self->config;
if ((pins & BIT(config->dio1_gpio.pin)) != 0U && data->dio1_user_handler != NULL) {
data->dio1_user_handler(data->self, data->dio1_user_data);
}
}
int llcc68_init(const struct device *dev) {
const struct llcc68_config *config = dev->config;
struct llcc68_data *data = dev->data;
if (config->tx_enable_gpio.port != NULL) {
gpio_pin_configure_dt(&config->tx_enable_gpio, GPIO_OUTPUT_INACTIVE);
}
if (config->rx_enable_gpio.port != NULL) {
gpio_pin_configure_dt(&config->rx_enable_gpio, GPIO_OUTPUT_INACTIVE);
}
gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_INACTIVE);
gpio_pin_configure_dt(&config->busy_gpio, GPIO_INPUT);
gpio_pin_configure_dt(&config->dio1_gpio, GPIO_INPUT);
data->self = dev;
gpio_init_callback(&data->dio1_irq_callback, dio1_irq_trampoline, BIT(config->dio1_gpio.pin));
if (gpio_add_callback(config->dio1_gpio.port, &data->dio1_irq_callback) < 0) {
return -EIO;
}
gpio_pin_interrupt_configure_dt(&config->dio1_gpio, GPIO_INT_DISABLE);
return 0;
}
#define LLCC68_DEFINE(inst) \
static struct llcc68_data llcc68_data_##inst; \
static const struct llcc68_config llcc68_config_##inst = \
{ \
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8) | SPI_TRANSFER_MSB), \
.reset_gpio = GPIO_DT_SPEC_INST_GET(inst, reset_gpios), \
.busy_gpio = GPIO_DT_SPEC_INST_GET(inst, busy_gpios), \
.dio1_gpio = GPIO_DT_SPEC_INST_GET(inst, dio1_gpios), \
.tx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, tx_enable_gpios, {.port = NULL}), \
.rx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, rx_enable_gpios, {.port = NULL}), \
}; \
DEVICE_DT_INST_DEFINE(inst, \
llcc68_init, \
NULL, \
&llcc68_data_##inst, \
&llcc68_config_##inst, \
POST_KERNEL, \
CONFIG_LLCC68_INIT_PRIORITY, \
NULL)
BUILD_ASSERT(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT),
"No status=okay nodes for DT_DRV_COMPAT; check compatible/status");
DT_INST_FOREACH_STATUS_OKAY(LLCC68_DEFINE)