fix(llcc68): align spi binding with zephyr
Add a module-local .gitignore entry for macOS .DS_Store artifacts so generated Finder metadata does not dirty the submodule. Declare the SPI chip-select delay binding properties as integers so Zephyr devicetree validation accepts the custom LLCC68 binding. Pass the configured setup delay into SPI_DT_SPEC_INST_GET using the Zephyr 4 three-argument API, converting the nanosecond devicetree value to the microsecond spi_cs_control delay field.
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
||||||
+37
-32
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <zephyr/devicetree.h>
|
#include <zephyr/devicetree.h>
|
||||||
|
#include <zephyr/sys_clock.h>
|
||||||
#include <zephyr/sys/util.h>
|
#include <zephyr/sys/util.h>
|
||||||
|
|
||||||
#define DT_DRV_COMPAT semtech_llcc68_weihua
|
#define DT_DRV_COMPAT semtech_llcc68_weihua
|
||||||
|
|
||||||
#define LLCC68_AUTO_RF_SWITCH_MODE(inst) \
|
#define LLCC68_AUTO_RF_SWITCH_MODE(inst) \
|
||||||
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, tx_enable_gpios), \
|
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, tx_enable_gpios), \
|
||||||
(COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, rx_enable_gpios), \
|
(COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, rx_enable_gpios), \
|
||||||
(LLCC68_RF_SWITCH_GPIO_COMPLEMENTARY), (LLCC68_RF_SWITCH_NONE))), \
|
(LLCC68_RF_SWITCH_GPIO_COMPLEMENTARY), (LLCC68_RF_SWITCH_NONE))), \
|
||||||
(LLCC68_RF_SWITCH_NONE))
|
(LLCC68_RF_SWITCH_NONE))
|
||||||
|
|
||||||
@@ -22,9 +23,12 @@
|
|||||||
#define LLCC68_DEFAULT_RF_SWITCH_MODE(inst) LLCC68_AUTO_RF_SWITCH_MODE(inst)
|
#define LLCC68_DEFAULT_RF_SWITCH_MODE(inst) LLCC68_AUTO_RF_SWITCH_MODE(inst)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LLCC68_RF_SWITCH_MODE(inst) \
|
#define LLCC68_RF_SWITCH_MODE(inst) \
|
||||||
DT_ENUM_IDX_OR(DT_DRV_INST(inst), rf_switch_mode, LLCC68_DEFAULT_RF_SWITCH_MODE(inst))
|
DT_ENUM_IDX_OR(DT_DRV_INST(inst), rf_switch_mode, LLCC68_DEFAULT_RF_SWITCH_MODE(inst))
|
||||||
|
|
||||||
|
#define LLCC68_SPI_CS_DELAY_US(inst) \
|
||||||
|
DIV_ROUND_UP(DT_INST_PROP(inst, spi_cs_setup_delay_ns), NSEC_PER_USEC)
|
||||||
|
|
||||||
static void dio1_irq_trampoline(const struct device *port, struct gpio_callback *cb, uint32_t pins) {
|
static void dio1_irq_trampoline(const struct device *port, struct gpio_callback *cb, uint32_t pins) {
|
||||||
ARG_UNUSED(port);
|
ARG_UNUSED(port);
|
||||||
|
|
||||||
@@ -69,34 +73,35 @@ int llcc68_init(const struct device *dev) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LLCC68_DEFINE(inst) \
|
#define LLCC68_DEFINE(inst) \
|
||||||
BUILD_ASSERT(LLCC68_RF_SWITCH_MODE(inst) != LLCC68_RF_SWITCH_GPIO_COMPLEMENTARY || \
|
BUILD_ASSERT(LLCC68_RF_SWITCH_MODE(inst) != LLCC68_RF_SWITCH_GPIO_COMPLEMENTARY || \
|
||||||
(DT_INST_NODE_HAS_PROP(inst, tx_enable_gpios) && \
|
(DT_INST_NODE_HAS_PROP(inst, tx_enable_gpios) && \
|
||||||
DT_INST_NODE_HAS_PROP(inst, rx_enable_gpios)), \
|
DT_INST_NODE_HAS_PROP(inst, rx_enable_gpios)), \
|
||||||
"LLCC68 gpio-complementary RF switch mode requires tx-enable-gpios " \
|
"LLCC68 gpio-complementary RF switch mode requires tx-enable-gpios " \
|
||||||
"and rx-enable-gpios"); \
|
"and rx-enable-gpios"); \
|
||||||
BUILD_ASSERT(LLCC68_RF_SWITCH_MODE(inst) != LLCC68_RF_SWITCH_DIO2_SINGLE || \
|
BUILD_ASSERT(LLCC68_RF_SWITCH_MODE(inst) != LLCC68_RF_SWITCH_DIO2_SINGLE || \
|
||||||
!DT_INST_NODE_HAS_PROP(inst, tx_enable_gpios), \
|
!DT_INST_NODE_HAS_PROP(inst, tx_enable_gpios), \
|
||||||
"LLCC68 dio2-single RF switch mode uses DIO2 for TXEN and must not " \
|
"LLCC68 dio2-single RF switch mode uses DIO2 for TXEN and must not " \
|
||||||
"define tx-enable-gpios"); \
|
"define tx-enable-gpios"); \
|
||||||
static struct llcc68_data llcc68_data_##inst; \
|
static struct llcc68_data llcc68_data_##inst; \
|
||||||
static const struct llcc68_config llcc68_config_##inst = \
|
static const struct llcc68_config llcc68_config_##inst = \
|
||||||
{ \
|
{ \
|
||||||
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8) | SPI_TRANSFER_MSB), \
|
.spi = SPI_DT_SPEC_INST_GET( \
|
||||||
.reset_gpio = GPIO_DT_SPEC_INST_GET(inst, reset_gpios), \
|
inst, SPI_WORD_SET(8) | SPI_TRANSFER_MSB, LLCC68_SPI_CS_DELAY_US(inst)), \
|
||||||
.busy_gpio = GPIO_DT_SPEC_INST_GET(inst, busy_gpios), \
|
.reset_gpio = GPIO_DT_SPEC_INST_GET(inst, reset_gpios), \
|
||||||
.dio1_gpio = GPIO_DT_SPEC_INST_GET(inst, dio1_gpios), \
|
.busy_gpio = GPIO_DT_SPEC_INST_GET(inst, busy_gpios), \
|
||||||
.tx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, tx_enable_gpios, {.port = NULL}), \
|
.dio1_gpio = GPIO_DT_SPEC_INST_GET(inst, dio1_gpios), \
|
||||||
.rx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, rx_enable_gpios, {.port = NULL}), \
|
.tx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, tx_enable_gpios, {.port = NULL}), \
|
||||||
.rf_switch_mode = LLCC68_RF_SWITCH_MODE(inst), \
|
.rx_enable_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, rx_enable_gpios, {.port = NULL}), \
|
||||||
}; \
|
.rf_switch_mode = LLCC68_RF_SWITCH_MODE(inst), \
|
||||||
DEVICE_DT_INST_DEFINE(inst, \
|
}; \
|
||||||
llcc68_init, \
|
DEVICE_DT_INST_DEFINE(inst, \
|
||||||
NULL, \
|
llcc68_init, \
|
||||||
&llcc68_data_##inst, \
|
NULL, \
|
||||||
&llcc68_config_##inst, \
|
&llcc68_data_##inst, \
|
||||||
POST_KERNEL, \
|
&llcc68_config_##inst, \
|
||||||
CONFIG_LLCC68_INIT_PRIORITY, \
|
POST_KERNEL, \
|
||||||
|
CONFIG_LLCC68_INIT_PRIORITY, \
|
||||||
NULL)
|
NULL)
|
||||||
|
|
||||||
BUILD_ASSERT(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT),
|
BUILD_ASSERT(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT),
|
||||||
|
|||||||
@@ -71,7 +71,9 @@ properties:
|
|||||||
which the driver holds active. This mode must not use tx-enable-gpios.
|
which the driver holds active. This mode must not use tx-enable-gpios.
|
||||||
|
|
||||||
spi-cs-setup-delay-ns:
|
spi-cs-setup-delay-ns:
|
||||||
|
type: int
|
||||||
default: 100000
|
default: 100000
|
||||||
|
|
||||||
spi-cs-hold-delay-ns:
|
spi-cs-hold-delay-ns:
|
||||||
|
type: int
|
||||||
default: 100000
|
default: 100000
|
||||||
|
|||||||
Reference in New Issue
Block a user