Lines Matching +full:uart +full:- +full:dev
4 * SPDX-License-Identifier: Apache-2.0
9 #include <zephyr/drivers/uart.h>
21 /* UART IRQ handler declaration. */
23 static void irq_config_uart_##n(const struct device *dev)
29 static void irq_config_uart_##n(const struct device *dev) \
31 ARG_UNUSED(dev); \
34 DEVICE_DT_GET(DT_NODELABEL(uart##n)), \
45 /* Device init macro for UART instance. As multiple uart instances follow a
66 PM_DEVICE_DT_DEFINE(DT_NODELABEL(uart##n), \
68 DEVICE_DT_DEFINE(DT_NODELABEL(uart##n), \
70 PM_DEVICE_DT_GET(DT_NODELABEL(uart##n)), \
79 #define GET_CONTROLLER_INSTANCE(dev) \ argument
81 dev->config)->instance)
83 #define GET_MUTEX(dev) \ argument
85 dev->config)->mutex)
89 /* Specifies the uart instance for configuration. */
92 /* Specifies the baudrate for the uart instance. */
100 /* Enable / disable hardware flow control for UART. */
103 /* UART irq configuration function when supporting interrupt
110 static int uart_sedi_init(const struct device *dev);
126 static void uart_busy_set(const struct device *dev) in uart_busy_set() argument
129 struct uart_sedi_drv_data *context = dev->data; in uart_busy_set()
131 context->busy_count++; in uart_busy_set()
133 if (context->busy_count == 1) { in uart_busy_set()
134 pm_device_busy_set(dev); in uart_busy_set()
138 static void uart_busy_clear(const struct device *dev) in uart_busy_clear() argument
141 struct uart_sedi_drv_data *context = dev->data; in uart_busy_clear()
143 context->busy_count--; in uart_busy_clear()
145 if (context->busy_count == 0) { in uart_busy_clear()
146 pm_device_busy_clear(dev); in uart_busy_clear()
155 static int uart_suspend_device(const struct device *dev) in uart_suspend_device() argument
157 const struct uart_sedi_config_info *config = dev->config; in uart_suspend_device()
159 if (pm_device_is_busy(dev)) { in uart_suspend_device()
160 return -EBUSY; in uart_suspend_device()
163 int ret = sedi_uart_set_power(config->instance, SEDI_POWER_SUSPEND); in uart_suspend_device()
166 return -EIO; in uart_suspend_device()
172 static int uart_resume_device_from_suspend(const struct device *dev) in uart_resume_device_from_suspend() argument
174 const struct uart_sedi_config_info *config = dev->config; in uart_resume_device_from_suspend()
177 ret = sedi_uart_set_power(config->instance, SEDI_POWER_FULL); in uart_resume_device_from_suspend()
179 return -EIO; in uart_resume_device_from_suspend()
185 static int uart_sedi_pm_action(const struct device *dev, in uart_sedi_pm_action() argument
192 ret = uart_suspend_device(dev); in uart_sedi_pm_action()
195 ret = uart_resume_device_from_suspend(dev); in uart_sedi_pm_action()
199 ret = -ENOTSUP; in uart_sedi_pm_action()
206 static int uart_sedi_pm_action(const struct device *dev, in uart_sedi_pm_action() argument
209 /* do nothing if using UART print log to avoid clock gating in uart_sedi_pm_action()
210 * pm driver already handled power management for uart. in uart_sedi_pm_action()
219 static int uart_sedi_poll_in(const struct device *dev, unsigned char *data) in uart_sedi_poll_in() argument
221 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_poll_in()
227 /* In order to check if there is any data to read from UART in uart_sedi_poll_in()
233 ret = -1; in uart_sedi_poll_in()
236 ret = -1; in uart_sedi_poll_in()
242 static void uart_sedi_poll_out(const struct device *dev, in uart_sedi_poll_out() argument
245 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_poll_out()
260 err = -ECANCELED; in get_xfer_error()
263 err = -EIO; in get_xfer_error()
266 err = -EINVAL; in get_xfer_error()
269 err = -ENOTSUP; in get_xfer_error()
272 err = -EFAULT; in get_xfer_error()
278 static int uart_sedi_err_check(const struct device *dev) in uart_sedi_err_check() argument
280 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_err_check()
307 static int uart_sedi_fifo_fill(const struct device *dev, const uint8_t *tx_data, in uart_sedi_fifo_fill() argument
310 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_fifo_fill()
315 static int uart_sedi_fifo_read(const struct device *dev, uint8_t *rx_data, in uart_sedi_fifo_read() argument
318 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_fifo_read()
323 static void uart_sedi_irq_tx_enable(const struct device *dev) in uart_sedi_irq_tx_enable() argument
325 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_tx_enable()
330 static void uart_sedi_irq_tx_disable(const struct device *dev) in uart_sedi_irq_tx_disable() argument
332 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_tx_disable()
337 static int uart_sedi_irq_tx_ready(const struct device *dev) in uart_sedi_irq_tx_ready() argument
339 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_tx_ready()
344 static int uart_sedi_irq_tx_complete(const struct device *dev) in uart_sedi_irq_tx_complete() argument
346 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_tx_complete()
351 static void uart_sedi_irq_rx_enable(const struct device *dev) in uart_sedi_irq_rx_enable() argument
353 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_rx_enable()
355 uart_busy_set(dev); in uart_sedi_irq_rx_enable()
359 static void uart_sedi_irq_rx_disable(const struct device *dev) in uart_sedi_irq_rx_disable() argument
361 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_rx_disable()
364 uart_busy_clear(dev); in uart_sedi_irq_rx_disable()
367 static int uart_sedi_irq_rx_ready(const struct device *dev) in uart_sedi_irq_rx_ready() argument
369 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_rx_ready()
374 static void uart_sedi_irq_err_enable(const struct device *dev) in uart_sedi_irq_err_enable() argument
376 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_err_enable()
381 static void uart_sedi_irq_err_disable(const struct device *dev) in uart_sedi_irq_err_disable() argument
383 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_err_disable()
388 static int uart_sedi_irq_is_pending(const struct device *dev) in uart_sedi_irq_is_pending() argument
391 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_is_pending()
396 static int uart_sedi_irq_update(const struct device *dev) in uart_sedi_irq_update() argument
398 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_irq_update()
404 static void uart_sedi_irq_callback_set(const struct device *dev, in uart_sedi_irq_callback_set() argument
408 struct uart_sedi_drv_data *drv_data = dev->data; in uart_sedi_irq_callback_set()
410 drv_data->user_cb = cb; in uart_sedi_irq_callback_set()
411 drv_data->user_data = user_data; in uart_sedi_irq_callback_set()
417 struct device *dev = arg; in uart_sedi_isr() local
418 struct uart_sedi_drv_data *drv_data = dev->data; in uart_sedi_isr()
420 if (drv_data->user_cb) { in uart_sedi_isr()
421 drv_data->user_cb(dev, drv_data->user_data); in uart_sedi_isr()
423 uart_sedi_cb(dev); in uart_sedi_isr()
438 static int uart_sedi_line_ctrl_set(struct device *dev, in uart_sedi_line_ctrl_set() argument
441 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_line_ctrl_set()
446 k_mutex_lock(GET_MUTEX(dev), K_FOREVER); in uart_sedi_line_ctrl_set()
455 ret = -ENODEV; in uart_sedi_line_ctrl_set()
457 k_mutex_unlock(GET_MUTEX(dev)); in uart_sedi_line_ctrl_set()
462 static int uart_sedi_line_ctrl_get(struct device *dev, in uart_sedi_line_ctrl_get() argument
465 sedi_uart_t instance = GET_CONTROLLER_INSTANCE(dev); in uart_sedi_line_ctrl_get()
470 k_mutex_lock(GET_MUTEX(dev), K_FOREVER); in uart_sedi_line_ctrl_get()
507 ret = -ENODEV; in uart_sedi_line_ctrl_get()
509 k_mutex_unlock(GET_MUTEX(dev)); in uart_sedi_line_ctrl_get()
516 static DEVICE_API(uart, api) = {
543 static int uart_sedi_init(const struct device *dev) in uart_sedi_init() argument
546 const struct uart_sedi_config_info *config = dev->config; in uart_sedi_init()
549 DEVICE_MMIO_MAP(dev, K_MEM_CACHE_NONE); in uart_sedi_init()
550 sedi_uart_init(config->instance, (void *)DEVICE_MMIO_GET(dev)); in uart_sedi_init()
552 cfg.line_control = config->line_ctrl; in uart_sedi_init()
553 cfg.baud_rate = config->baud_rate; in uart_sedi_init()
554 cfg.hw_fc = config->hw_fc; in uart_sedi_init()
557 sedi_uart_set_power(config->instance, SEDI_POWER_FULL); in uart_sedi_init()
559 sedi_uart_set_config(config->instance, &cfg); in uart_sedi_init()
562 config->uart_irq_config_func(dev); in uart_sedi_init()