Skip to content

Commit 1015495

Browse files
telink: driver: add flow control to W91 serial driver
Added flow control to W91 serial driver Signed-off-by: Serhii Salamakha <serhii.salamakha@gmail.com>
1 parent e8f404c commit 1015495

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

drivers/serial/uart_w91.c

+15-13
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ static size_t pack_uart_w91_configure(uint8_t inst, void *unpack_data, uint8_t *
144144

145145
IPC_DISPATCHER_UNPACK_FUNC_ONLY_WITH_ERROR_PARAM(uart_w91_configure);
146146

147-
static int uart_w91_configure(const struct device *dev,
148-
const struct uart_config *cfg)
147+
static int uart_w91_configure(const struct device *dev, const struct uart_config *cfg)
149148
{
150149
int err = -ETIMEDOUT;
151150
struct uart_w91_config_req config_req = {};
@@ -187,8 +186,10 @@ static int uart_w91_configure(const struct device *dev,
187186
}
188187

189188
/* check flow control */
190-
if (cfg->flow_ctrl != UART_CFG_FLOW_CTRL_NONE &&
191-
cfg->flow_ctrl != UART_CFG_FLOW_CTRL_RTS_CTS) {
189+
if (cfg->flow_ctrl == UART_CFG_FLOW_CTRL_NONE ||
190+
cfg->flow_ctrl == UART_CFG_FLOW_CTRL_RTS_CTS) {
191+
config_req.flow_ctrl = cfg->flow_ctrl;
192+
} else {
192193
return -ENOTSUP;
193194
}
194195

@@ -296,8 +297,7 @@ static int uart_w91_read(const struct device *dev, uint8_t *rx_data, const int s
296297
}
297298

298299
/* API implementation: config_get */
299-
static int uart_w91_config_get(const struct device *dev,
300-
struct uart_config *cfg)
300+
static int uart_w91_config_get(const struct device *dev, struct uart_config *cfg)
301301
{
302302
struct uart_w91_data *data = dev->data;
303303

@@ -625,13 +625,14 @@ static int uart_w91_driver_init(const struct device *dev)
625625
int err;
626626
const struct uart_w91_config *cfg = dev->config;
627627
struct uart_w91_data *data = dev->data;
628-
struct uart_config *config = &data->cfg;
629-
uint8_t inst = ((struct uart_w91_config *)dev->config)->instance_id;
628+
struct uart_config config;
630629

631630
ipc_based_driver_init(&data->ipc);
632631

633632
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
634633
/* once for all UART instances */
634+
uint8_t inst = ((struct uart_w91_config *)dev->config)->instance_id;
635+
635636
if (!uart_irq_thread_initialized) {
636637
k_tid_t thread_id = k_thread_create(&uart_irq_thread_data,
637638
uart_irq_thread_stack, K_THREAD_STACK_SIZEOF(uart_irq_thread_stack),
@@ -656,12 +657,13 @@ static int uart_w91_driver_init(const struct device *dev)
656657
return err;
657658
}
658659

659-
data->cfg.baudrate = cfg->baud_rate;
660-
data->cfg.data_bits = UART_CFG_DATA_BITS_8;
661-
data->cfg.parity = UART_CFG_PARITY_NONE;
662-
data->cfg.stop_bits = UART_CFG_STOP_BITS_1;
660+
config.baudrate = cfg->baud_rate;
661+
config.parity = UART_CFG_PARITY_NONE;
662+
config.stop_bits = UART_CFG_STOP_BITS_1;
663+
config.data_bits = UART_CFG_DATA_BITS_8;
664+
config.flow_ctrl = cfg->hw_flow_control;
663665

664-
err = uart_w91_configure(dev, config);
666+
err = uart_w91_configure(dev, &config);
665667

666668
return err;
667669
}

soc/telink/tlsr/telink_w9x/Kconfig.n22

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ config TELINK_W91_FETCH_N22_BIN
1515

1616
config TELINK_W91_FETCH_N22_BIN_REVISION
1717
string "N22 binaries revision"
18-
default "4d7b3e5962b9d34e28f7b24981ebac7e969b1115"
18+
default "d8382c780eafd8d33c5d3b186c42404527022cd4"
1919
depends on TELINK_W91_FETCH_N22_BIN
2020
help
2121
This option sets N22 binary revision.

0 commit comments

Comments
 (0)