Lines Matching full:data

112 /* driver data */
137 struct uart_esp32_data *data = dev->data; in uart_esp32_poll_in() local
140 if (uart_hal_get_rxfifo_len(&data->hal) == 0) { in uart_esp32_poll_in()
144 uart_hal_read_rxfifo(&data->hal, p_char, &inout_rd_len); in uart_esp32_poll_in()
151 struct uart_esp32_data *data = dev->data; in uart_esp32_poll_out() local
155 while (uart_hal_get_txfifo_len(&data->hal) == 0) { in uart_esp32_poll_out()
160 uart_hal_write_txfifo(&data->hal, &c, 1, &written); in uart_esp32_poll_out()
165 struct uart_esp32_data *data = dev->data; in uart_esp32_err_check() local
166 uint32_t mask = uart_hal_get_intsts_mask(&data->hal); in uart_esp32_err_check()
198 struct uart_esp32_data *data = dev->data; in uart_esp32_config_get() local
207 uart_hal_get_sclk(&data->hal, &src_clk); in uart_esp32_config_get()
211 uart_hal_get_baudrate(&data->hal, &calc_baud, sclk_freq); in uart_esp32_config_get()
214 uart_hal_get_parity(&data->hal, &parity); in uart_esp32_config_get()
229 uart_hal_get_stop_bits(&data->hal, &stop_bit); in uart_esp32_config_get()
244 uart_hal_get_data_bit_num(&data->hal, &data_bit); in uart_esp32_config_get()
262 uart_hal_get_hw_flow_ctrl(&data->hal, &hw_flow); in uart_esp32_config_get()
274 if (uart_hal_is_mode_rs485_half_duplex(&data->hal)) { in uart_esp32_config_get()
285 struct uart_esp32_data *data = dev->data; in uart_esp32_configure() local
301 uart_hal_set_sclk(&data->hal, UART_SCLK_DEFAULT); in uart_esp32_configure()
302 uart_hal_set_rxfifo_full_thr(&data->hal, UART_RX_FIFO_THRESH); in uart_esp32_configure()
303 uart_hal_set_txfifo_empty_thr(&data->hal, UART_TX_FIFO_THRESH); in uart_esp32_configure()
304 uart_hal_rxfifo_rst(&data->hal); in uart_esp32_configure()
305 uart_hal_txfifo_rst(&data->hal); in uart_esp32_configure()
309 uart_hal_set_parity(&data->hal, UART_PARITY_DISABLE); in uart_esp32_configure()
312 uart_hal_set_parity(&data->hal, UART_PARITY_EVEN); in uart_esp32_configure()
315 uart_hal_set_parity(&data->hal, UART_PARITY_ODD); in uart_esp32_configure()
323 uart_hal_set_stop_bits(&data->hal, UART_STOP_BITS_1); in uart_esp32_configure()
326 uart_hal_set_stop_bits(&data->hal, UART_STOP_BITS_1_5); in uart_esp32_configure()
329 uart_hal_set_stop_bits(&data->hal, UART_STOP_BITS_2); in uart_esp32_configure()
337 uart_hal_set_data_bit_num(&data->hal, UART_DATA_5_BITS); in uart_esp32_configure()
340 uart_hal_set_data_bit_num(&data->hal, UART_DATA_6_BITS); in uart_esp32_configure()
343 uart_hal_set_data_bit_num(&data->hal, UART_DATA_7_BITS); in uart_esp32_configure()
346 uart_hal_set_data_bit_num(&data->hal, UART_DATA_8_BITS); in uart_esp32_configure()
352 uart_hal_set_mode(&data->hal, UART_MODE_UART); in uart_esp32_configure()
356 uart_hal_set_hw_flow_ctrl(&data->hal, UART_HW_FLOWCTRL_DISABLE, 0); in uart_esp32_configure()
359 uart_hal_set_hw_flow_ctrl(&data->hal, UART_HW_FLOWCTRL_CTS_RTS, 10); in uart_esp32_configure()
362 uart_hal_set_mode(&data->hal, UART_MODE_RS485_HALF_DUPLEX); in uart_esp32_configure()
368 uart_hal_get_sclk(&data->hal, &src_clk); in uart_esp32_configure()
371 uart_hal_set_baudrate(&data->hal, cfg->baudrate, sclk_freq); in uart_esp32_configure()
373 uart_hal_set_rx_timeout(&data->hal, 0x16); in uart_esp32_configure()
376 uart_hal_inverse_signal(&data->hal, UART_SIGNAL_TXD_INV); in uart_esp32_configure()
380 uart_hal_inverse_signal(&data->hal, UART_SIGNAL_RXD_INV); in uart_esp32_configure()
389 struct uart_esp32_data *data = dev->data; in uart_esp32_fifo_fill() local
396 uart_hal_write_txfifo(&data->hal, tx_data, len, &written); in uart_esp32_fifo_fill()
402 struct uart_esp32_data *data = dev->data; in uart_esp32_fifo_read() local
403 const int num_rx = uart_hal_get_rxfifo_len(&data->hal); in uart_esp32_fifo_read()
410 uart_hal_read_rxfifo(&data->hal, rx_data, &read); in uart_esp32_fifo_read()
416 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_tx_enable() local
418 uart_hal_clr_intsts_mask(&data->hal, UART_INTR_TXFIFO_EMPTY); in uart_esp32_irq_tx_enable()
419 uart_hal_ena_intr_mask(&data->hal, UART_INTR_TXFIFO_EMPTY); in uart_esp32_irq_tx_enable()
424 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_tx_disable() local
426 uart_hal_disable_intr_mask(&data->hal, UART_INTR_TXFIFO_EMPTY); in uart_esp32_irq_tx_disable()
431 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_tx_ready() local
433 return (uart_hal_get_txfifo_len(&data->hal) > 0 && in uart_esp32_irq_tx_ready()
434 uart_hal_get_intr_ena_status(&data->hal) & UART_INTR_TXFIFO_EMPTY); in uart_esp32_irq_tx_ready()
439 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_rx_disable() local
441 uart_hal_disable_intr_mask(&data->hal, UART_INTR_RXFIFO_FULL); in uart_esp32_irq_rx_disable()
442 uart_hal_disable_intr_mask(&data->hal, UART_INTR_RXFIFO_TOUT); in uart_esp32_irq_rx_disable()
447 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_tx_complete() local
449 return uart_hal_is_tx_idle(&data->hal); in uart_esp32_irq_tx_complete()
454 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_rx_ready() local
456 return (uart_hal_get_rxfifo_len(&data->hal) > 0); in uart_esp32_irq_rx_ready()
461 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_err_enable() local
464 uart_hal_ena_intr_mask(&data->hal, UART_INTR_FRAM_ERR); in uart_esp32_irq_err_enable()
465 uart_hal_ena_intr_mask(&data->hal, UART_INTR_PARITY_ERR); in uart_esp32_irq_err_enable()
470 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_err_disable() local
472 uart_hal_disable_intr_mask(&data->hal, UART_INTR_FRAM_ERR); in uart_esp32_irq_err_disable()
473 uart_hal_disable_intr_mask(&data->hal, UART_INTR_PARITY_ERR); in uart_esp32_irq_err_disable()
483 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_update() local
485 uart_hal_clr_intsts_mask(&data->hal, UART_INTR_RXFIFO_FULL); in uart_esp32_irq_update()
486 uart_hal_clr_intsts_mask(&data->hal, UART_INTR_RXFIFO_TOUT); in uart_esp32_irq_update()
487 uart_hal_clr_intsts_mask(&data->hal, UART_INTR_TXFIFO_EMPTY); in uart_esp32_irq_update()
495 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_callback_set() local
497 data->irq_cb = cb; in uart_esp32_irq_callback_set()
498 data->irq_cb_data = cb_data; in uart_esp32_irq_callback_set()
501 data->async.cb = NULL; in uart_esp32_irq_callback_set()
502 data->async.user_data = NULL; in uart_esp32_irq_callback_set()
523 struct uart_esp32_data *data = dev->data; in uart_esp32_irq_rx_enable() local
525 uart_hal_clr_intsts_mask(&data->hal, UART_INTR_RXFIFO_FULL); in uart_esp32_irq_rx_enable()
526 uart_hal_clr_intsts_mask(&data->hal, UART_INTR_RXFIFO_TOUT); in uart_esp32_irq_rx_enable()
527 uart_hal_ena_intr_mask(&data->hal, UART_INTR_RXFIFO_FULL); in uart_esp32_irq_rx_enable()
528 uart_hal_ena_intr_mask(&data->hal, UART_INTR_RXFIFO_TOUT); in uart_esp32_irq_rx_enable()
534 struct uart_esp32_data *data = dev->data; in uart_esp32_isr() local
535 uint32_t uart_intr_status = uart_hal_get_intsts_mask(&data->hal); in uart_esp32_isr()
540 uart_hal_clr_intsts_mask(&data->hal, uart_intr_status); in uart_esp32_isr()
544 if (data->irq_cb) { in uart_esp32_isr()
545 data->irq_cb(dev, data->irq_cb_data); in uart_esp32_isr()
551 data->async.rx_counter++; in uart_esp32_isr()
552 uart_esp32_async_timer_start(&data->async.rx_timeout_work, data->async.rx_timeout); in uart_esp32_isr()
565 struct uart_esp32_data *data = uart_dev->data; in uart_esp32_dma_rx_done() local
572 if (data->async.rx_counter != data->async.rx_len) { in uart_esp32_dma_rx_done()
574 (uint32_t)data->async.rx_buf + data->async.rx_counter, in uart_esp32_dma_rx_done()
575 data->async.rx_len - data->async.rx_counter); in uart_esp32_dma_rx_done()
577 data->uhci_dev->pkt_thres.thrs = data->async.rx_len - data->async.rx_counter; in uart_esp32_dma_rx_done()
584 evt.data.rx.buf = data->async.rx_buf; in uart_esp32_dma_rx_done()
585 evt.data.rx.len = data->async.rx_counter - data->async.rx_offset; in uart_esp32_dma_rx_done()
586 evt.data.rx.offset = data->async.rx_offset; in uart_esp32_dma_rx_done()
588 if (data->async.cb && evt.data.rx.len) { in uart_esp32_dma_rx_done()
589 data->async.cb(data->uart_dev, &evt, data->async.user_data); in uart_esp32_dma_rx_done()
592 data->async.rx_offset = 0; in uart_esp32_dma_rx_done()
593 data->async.rx_counter = 0; in uart_esp32_dma_rx_done()
597 evt.data.rx_buf.buf = data->async.rx_buf; in uart_esp32_dma_rx_done()
598 if (data->async.cb) { in uart_esp32_dma_rx_done()
599 data->async.cb(uart_dev, &evt, data->async.user_data); in uart_esp32_dma_rx_done()
603 data->async.rx_buf = data->async.rx_next_buf; in uart_esp32_dma_rx_done()
604 data->async.rx_len = data->async.rx_next_len; in uart_esp32_dma_rx_done()
605 data->async.rx_next_buf = NULL; in uart_esp32_dma_rx_done()
606 data->async.rx_next_len = 0U; in uart_esp32_dma_rx_done()
608 if (data->async.cb) { in uart_esp32_dma_rx_done()
609 data->async.cb(uart_dev, &evt, data->async.user_data); in uart_esp32_dma_rx_done()
613 if (!data->async.rx_buf) { in uart_esp32_dma_rx_done()
615 if (data->async.cb) { in uart_esp32_dma_rx_done()
616 data->async.cb(uart_dev, &evt, data->async.user_data); in uart_esp32_dma_rx_done()
620 dma_reload(config->dma_dev, config->rx_dma_channel, 0, (uint32_t)data->async.rx_buf, in uart_esp32_dma_rx_done()
621 data->async.rx_len); in uart_esp32_dma_rx_done()
623 data->uhci_dev->pkt_thres.thrs = data->async.rx_len; in uart_esp32_dma_rx_done()
633 struct uart_esp32_data *data = uart_dev->data; in uart_esp32_dma_tx_done() local
637 k_work_cancel_delayable(&data->async.tx_timeout_work); in uart_esp32_dma_tx_done()
640 evt.data.tx.buf = data->async.tx_buf; in uart_esp32_dma_tx_done()
641 evt.data.tx.len = data->async.tx_len; in uart_esp32_dma_tx_done()
642 if (data->async.cb) { in uart_esp32_dma_tx_done()
643 data->async.cb(uart_dev, &evt, data->async.user_data); in uart_esp32_dma_tx_done()
647 data->async.tx_buf = NULL; in uart_esp32_dma_tx_done()
648 data->async.tx_len = 0U; in uart_esp32_dma_tx_done()
655 struct uart_esp32_data *data = dev->data; in uart_esp32_async_tx_abort() local
660 k_work_cancel_delayable(&data->async.tx_timeout_work); in uart_esp32_async_tx_abort()
669 evt.data.tx.buf = data->async.tx_buf; in uart_esp32_async_tx_abort()
670 evt.data.tx.len = data->async.tx_len; in uart_esp32_async_tx_abort()
672 if (data->async.cb) { in uart_esp32_async_tx_abort()
673 data->async.cb(dev, &evt, data->async.user_data); in uart_esp32_async_tx_abort()
686 struct uart_esp32_data *data = CONTAINER_OF(async, struct uart_esp32_data, async); in uart_esp32_async_tx_timeout() local
688 uart_esp32_async_tx_abort(data->uart_dev); in uart_esp32_async_tx_timeout()
696 struct uart_esp32_data *data = CONTAINER_OF(async, struct uart_esp32_data, async); in uart_esp32_async_rx_timeout() local
701 evt.data.rx.buf = data->async.rx_buf; in uart_esp32_async_rx_timeout()
702 evt.data.rx.len = data->async.rx_counter - data->async.rx_offset; in uart_esp32_async_rx_timeout()
703 evt.data.rx.offset = data->async.rx_offset; in uart_esp32_async_rx_timeout()
705 if (data->async.cb && evt.data.rx.len) { in uart_esp32_async_rx_timeout()
706 data->async.cb(data->uart_dev, &evt, data->async.user_data); in uart_esp32_async_rx_timeout()
709 data->async.rx_offset = data->async.rx_counter; in uart_esp32_async_rx_timeout()
710 k_work_cancel_delayable(&data->async.rx_timeout_work); in uart_esp32_async_rx_timeout()
717 struct uart_esp32_data *data = dev->data; in uart_esp32_async_callback_set() local
723 data->async.cb = callback; in uart_esp32_async_callback_set()
724 data->async.user_data = user_data; in uart_esp32_async_callback_set()
727 data->irq_cb = NULL; in uart_esp32_async_callback_set()
728 data->irq_cb_data = NULL; in uart_esp32_async_callback_set()
738 struct uart_esp32_data *data = dev->data; in uart_esp32_async_tx() local
763 data->async.tx_buf = buf; in uart_esp32_async_tx()
764 data->async.tx_len = len; in uart_esp32_async_tx()
781 uart_esp32_async_timer_start(&data->async.tx_timeout_work, timeout); in uart_esp32_async_tx()
798 struct uart_esp32_data *data = dev->data; in uart_esp32_async_rx_enable() local
823 data->async.rx_buf = buf; in uart_esp32_async_rx_enable()
824 data->async.rx_len = len; in uart_esp32_async_rx_enable()
825 data->async.rx_timeout = timeout; in uart_esp32_async_rx_enable()
834 dma_blk.dest_address = (uint32_t)data->async.rx_buf; in uart_esp32_async_rx_enable()
845 uart_hal_set_rxfifo_full_thr(&data->hal, 1); in uart_esp32_async_rx_enable()
854 data->uhci_dev->pkt_thres.thrs = len; in uart_esp32_async_rx_enable()
860 if (data->async.cb) { in uart_esp32_async_rx_enable()
861 data->async.cb(dev, &evt, data->async.user_data); in uart_esp32_async_rx_enable()
871 struct uart_esp32_data *data = dev->data; in uart_esp32_async_rx_buf_rsp() local
873 data->async.rx_next_buf = buf; in uart_esp32_async_rx_buf_rsp()
874 data->async.rx_next_len = len; in uart_esp32_async_rx_buf_rsp()
882 struct uart_esp32_data *data = dev->data; in uart_esp32_async_rx_disable() local
887 k_work_cancel_delayable(&data->async.rx_timeout_work); in uart_esp32_async_rx_disable()
889 if (!data->async.rx_len) { in uart_esp32_async_rx_disable()
902 evt.data.rx.buf = data->async.rx_buf; in uart_esp32_async_rx_disable()
903 evt.data.rx.len = data->async.rx_counter - data->async.rx_offset; in uart_esp32_async_rx_disable()
904 evt.data.rx.offset = data->async.rx_offset; in uart_esp32_async_rx_disable()
906 if (data->async.cb && evt.data.rx.len) { in uart_esp32_async_rx_disable()
907 data->async.cb(data->uart_dev, &evt, data->async.user_data); in uart_esp32_async_rx_disable()
910 data->async.rx_offset = 0; in uart_esp32_async_rx_disable()
911 data->async.rx_counter = 0; in uart_esp32_async_rx_disable()
915 evt.data.rx_buf.buf = data->async.rx_buf; in uart_esp32_async_rx_disable()
917 if (data->async.cb) { in uart_esp32_async_rx_disable()
918 data->async.cb(dev, &evt, data->async.user_data); in uart_esp32_async_rx_disable()
921 data->async.rx_len = 0; in uart_esp32_async_rx_disable()
922 data->async.rx_buf = NULL; in uart_esp32_async_rx_disable()
925 if (data->async.rx_next_len) { in uart_esp32_async_rx_disable()
927 evt.data.rx_buf.buf = data->async.rx_next_buf; in uart_esp32_async_rx_disable()
928 if (data->async.cb) { in uart_esp32_async_rx_disable()
929 data->async.cb(dev, &evt, data->async.user_data); in uart_esp32_async_rx_disable()
932 data->async.rx_next_len = 0; in uart_esp32_async_rx_disable()
933 data->async.rx_next_buf = NULL; in uart_esp32_async_rx_disable()
938 if (data->async.cb) { in uart_esp32_async_rx_disable()
939 data->async.cb(dev, &evt, data->async.user_data); in uart_esp32_async_rx_disable()
951 struct uart_esp32_data *data = dev->data; in uart_esp32_init() local
952 int ret = uart_esp32_configure(dev, &data->uart_config); in uart_esp32_init()
981 uhci_ll_init(data->uhci_dev); in uart_esp32_init()
982 uhci_ll_set_eof_mode(data->uhci_dev, UHCI_RX_IDLE_EOF | UHCI_RX_LEN_EOF); in uart_esp32_init()
983 uhci_ll_attach_uart_port(data->uhci_dev, uart_hal_get_port_num(&data->hal)); in uart_esp32_init()
984 data->uart_dev = dev; in uart_esp32_init()
986 k_work_init_delayable(&data->async.tx_timeout_work, uart_esp32_async_tx_timeout); in uart_esp32_init()
987 k_work_init_delayable(&data->async.rx_timeout_work, uart_esp32_async_rx_timeout); in uart_esp32_init()