Lines Matching full:data
151 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_isr() local
154 if (data->user_cb) { in uart_xmc4xxx_isr()
155 data->user_cb(dev, data->user_data); in uart_xmc4xxx_isr()
163 if (data->dma_rx.buffer_len) { in uart_xmc4xxx_isr()
171 async_timer_start(&data->dma_rx.timeout_work, data->dma_rx.timeout); in uart_xmc4xxx_isr()
179 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_configure_service_requests() local
184 data->service_request_tx = (config->irq_num_tx - USIC_IRQ_MIN) % IRQS_PER_USIC; in uart_xmc4xxx_configure_service_requests()
189 data->service_request_tx); in uart_xmc4xxx_configure_service_requests()
193 data->service_request_tx); in uart_xmc4xxx_configure_service_requests()
198 data->service_request_rx = (config->irq_num_rx - USIC_IRQ_MIN) % IRQS_PER_USIC; in uart_xmc4xxx_configure_service_requests()
203 data->service_request_rx); in uart_xmc4xxx_configure_service_requests()
206 data->service_request_rx); in uart_xmc4xxx_configure_service_requests()
210 data->service_request_rx); in uart_xmc4xxx_configure_service_requests()
213 data->service_request_rx); in uart_xmc4xxx_configure_service_requests()
323 const struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_irq_tx_enable() local
330 XMC_USIC_CH_TriggerServiceRequest(config->uart, data->service_request_tx); in uart_xmc4xxx_irq_tx_enable()
359 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_irq_callback_set() local
361 data->user_cb = cb; in uart_xmc4xxx_irq_callback_set()
362 data->user_data = user_data; in uart_xmc4xxx_irq_callback_set()
365 data->async_cb = NULL; in uart_xmc4xxx_irq_callback_set()
366 data->async_user_data = NULL; in uart_xmc4xxx_irq_callback_set()
395 static inline void async_evt_rx_buf_request(struct uart_xmc4xxx_data *data) in async_evt_rx_buf_request() argument
399 if (data->async_cb) { in async_evt_rx_buf_request()
400 data->async_cb(data->dev, &evt, data->async_user_data); in async_evt_rx_buf_request()
404 static inline void async_evt_rx_release_buffer(struct uart_xmc4xxx_data *data, int buffer_type) in async_evt_rx_release_buffer() argument
408 if (buffer_type == NEXT_BUFFER && !data->rx_next_buffer) { in async_evt_rx_release_buffer()
412 if (buffer_type == CURRENT_BUFFER && !data->dma_rx.buffer) { in async_evt_rx_release_buffer()
417 event.data.rx_buf.buf = data->rx_next_buffer; in async_evt_rx_release_buffer()
418 data->rx_next_buffer = NULL; in async_evt_rx_release_buffer()
419 data->rx_next_buffer_len = 0; in async_evt_rx_release_buffer()
421 event.data.rx_buf.buf = data->dma_rx.buffer; in async_evt_rx_release_buffer()
422 data->dma_rx.buffer = NULL; in async_evt_rx_release_buffer()
423 data->dma_rx.buffer_len = 0; in async_evt_rx_release_buffer()
426 if (data->async_cb) { in async_evt_rx_release_buffer()
427 data->async_cb(data->dev, &event, data->async_user_data); in async_evt_rx_release_buffer()
431 static inline void async_evt_rx_stopped(struct uart_xmc4xxx_data *data, in async_evt_rx_stopped() argument
434 struct uart_event event = {.type = UART_RX_STOPPED, .data.rx_stop.reason = reason}; in async_evt_rx_stopped()
435 struct uart_event_rx *rx = &event.data.rx_stop.data; in async_evt_rx_stopped()
438 if (data->dma_rx.buffer_len == 0 || data->async_cb == NULL) { in async_evt_rx_stopped()
442 rx->buf = data->dma_rx.buffer; in async_evt_rx_stopped()
443 if (dma_get_status(data->dma_rx.dma_dev, data->dma_rx.dma_channel, &stat) == 0) { in async_evt_rx_stopped()
444 data->dma_rx.counter = data->dma_rx.buffer_len - stat.pending_length; in async_evt_rx_stopped()
447 rx->len = data->dma_rx.counter - data->dma_rx.offset; in async_evt_rx_stopped()
448 rx->offset = data->dma_rx.counter; in async_evt_rx_stopped()
450 data->async_cb(data->dev, &event, data->async_user_data); in async_evt_rx_stopped()
453 static inline void async_evt_rx_disabled(struct uart_xmc4xxx_data *data) in async_evt_rx_disabled() argument
457 data->dma_rx.buffer = NULL; in async_evt_rx_disabled()
458 data->dma_rx.buffer_len = 0; in async_evt_rx_disabled()
459 data->dma_rx.offset = 0; in async_evt_rx_disabled()
460 data->dma_rx.counter = 0; in async_evt_rx_disabled()
462 if (data->async_cb) { in async_evt_rx_disabled()
463 data->async_cb(data->dev, &event, data->async_user_data); in async_evt_rx_disabled()
467 static inline void async_evt_rx_rdy(struct uart_xmc4xxx_data *data) in async_evt_rx_rdy() argument
470 .data.rx.buf = (uint8_t *)data->dma_rx.buffer, in async_evt_rx_rdy()
471 .data.rx.len = data->dma_rx.counter - data->dma_rx.offset, in async_evt_rx_rdy()
472 .data.rx.offset = data->dma_rx.offset}; in async_evt_rx_rdy()
474 data->dma_rx.offset = data->dma_rx.counter; in async_evt_rx_rdy()
476 if (event.data.rx.len > 0 && data->async_cb) { in async_evt_rx_rdy()
477 data->async_cb(data->dev, &event, data->async_user_data); in async_evt_rx_rdy()
481 static inline void async_evt_tx_done(struct uart_xmc4xxx_data *data) in async_evt_tx_done() argument
484 .data.tx.buf = data->dma_tx.buffer, in async_evt_tx_done()
485 .data.tx.len = data->dma_tx.counter}; in async_evt_tx_done()
487 data->dma_tx.buffer = NULL; in async_evt_tx_done()
488 data->dma_tx.buffer_len = 0; in async_evt_tx_done()
489 data->dma_tx.counter = 0; in async_evt_tx_done()
491 if (data->async_cb) { in async_evt_tx_done()
492 data->async_cb(data->dev, &event, data->async_user_data); in async_evt_tx_done()
496 static inline void async_evt_tx_abort(struct uart_xmc4xxx_data *data) in async_evt_tx_abort() argument
499 .data.tx.buf = data->dma_tx.buffer, in async_evt_tx_abort()
500 .data.tx.len = data->dma_tx.counter}; in async_evt_tx_abort()
502 data->dma_tx.buffer = NULL; in async_evt_tx_abort()
503 data->dma_tx.buffer_len = 0; in async_evt_tx_abort()
504 data->dma_tx.counter = 0; in async_evt_tx_abort()
506 if (data->async_cb) { in async_evt_tx_abort()
507 data->async_cb(data->dev, &event, data->async_user_data); in async_evt_tx_abort()
516 struct uart_xmc4xxx_data *data = CONTAINER_OF(rx_stream, struct uart_xmc4xxx_data, dma_rx); in uart_xmc4xxx_async_rx_timeout() local
520 if (data->dma_rx.buffer_len == 0) { in uart_xmc4xxx_async_rx_timeout()
525 if (dma_get_status(data->dma_rx.dma_dev, data->dma_rx.dma_channel, &stat) == 0) { in uart_xmc4xxx_async_rx_timeout()
526 size_t rx_rcv_len = data->dma_rx.buffer_len - stat.pending_length; in uart_xmc4xxx_async_rx_timeout()
528 if (rx_rcv_len > data->dma_rx.offset) { in uart_xmc4xxx_async_rx_timeout()
529 data->dma_rx.counter = rx_rcv_len; in uart_xmc4xxx_async_rx_timeout()
530 async_evt_rx_rdy(data); in uart_xmc4xxx_async_rx_timeout()
534 async_timer_start(&data->dma_rx.timeout_work, data->dma_rx.timeout); in uart_xmc4xxx_async_rx_timeout()
539 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_async_tx_abort() local
544 k_work_cancel_delayable(&data->dma_tx.timeout_work); in uart_xmc4xxx_async_tx_abort()
545 tx_buffer_len = data->dma_tx.buffer_len; in uart_xmc4xxx_async_tx_abort()
552 if (!dma_get_status(data->dma_tx.dma_dev, data->dma_tx.dma_channel, &stat)) { in uart_xmc4xxx_async_tx_abort()
553 data->dma_tx.counter = tx_buffer_len - stat.pending_length; in uart_xmc4xxx_async_tx_abort()
556 dma_stop(data->dma_tx.dma_dev, data->dma_tx.dma_channel); in uart_xmc4xxx_async_tx_abort()
558 async_evt_tx_abort(data); in uart_xmc4xxx_async_tx_abort()
570 struct uart_xmc4xxx_data *data = CONTAINER_OF(tx_stream, struct uart_xmc4xxx_data, dma_tx); in uart_xmc4xxx_async_tx_timeout() local
572 uart_xmc4xxx_async_tx_abort(data->dev); in uart_xmc4xxx_async_tx_timeout()
578 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_async_init() local
580 data->dev = dev; in uart_xmc4xxx_async_init()
582 if (data->dma_rx.dma_dev != NULL) { in uart_xmc4xxx_async_init()
583 if (!device_is_ready(data->dma_rx.dma_dev)) { in uart_xmc4xxx_async_init()
587 k_work_init_delayable(&data->dma_rx.timeout_work, uart_xmc4xxx_async_rx_timeout); in uart_xmc4xxx_async_init()
589 data->dma_rx.blk_cfg.source_address = (uint32_t)&config->uart->OUTR; in uart_xmc4xxx_async_init()
591 data->dma_rx.blk_cfg.source_address = (uint32_t)&config->uart->RBUF; in uart_xmc4xxx_async_init()
594 data->dma_rx.blk_cfg.source_addr_adj = DMA_ADDR_ADJ_NO_CHANGE; in uart_xmc4xxx_async_init()
595 data->dma_rx.blk_cfg.dest_addr_adj = DMA_ADDR_ADJ_INCREMENT; in uart_xmc4xxx_async_init()
596 data->dma_rx.dma_cfg.head_block = &data->dma_rx.blk_cfg; in uart_xmc4xxx_async_init()
597 data->dma_rx.dma_cfg.user_data = (void *)dev; in uart_xmc4xxx_async_init()
600 if (data->dma_tx.dma_dev != NULL) { in uart_xmc4xxx_async_init()
601 if (!device_is_ready(data->dma_tx.dma_dev)) { in uart_xmc4xxx_async_init()
605 k_work_init_delayable(&data->dma_tx.timeout_work, uart_xmc4xxx_async_tx_timeout); in uart_xmc4xxx_async_init()
608 data->dma_tx.blk_cfg.dest_address = (uint32_t)&config->uart->IN[0]; in uart_xmc4xxx_async_init()
610 data->dma_tx.blk_cfg.dest_address = (uint32_t)&config->uart->TBUF[0]; in uart_xmc4xxx_async_init()
613 data->dma_tx.blk_cfg.source_addr_adj = DMA_ADDR_ADJ_INCREMENT; in uart_xmc4xxx_async_init()
614 data->dma_tx.blk_cfg.dest_addr_adj = DMA_ADDR_ADJ_NO_CHANGE; in uart_xmc4xxx_async_init()
615 data->dma_tx.dma_cfg.head_block = &data->dma_tx.blk_cfg; in uart_xmc4xxx_async_init()
616 data->dma_tx.dma_cfg.user_data = (void *)dev; in uart_xmc4xxx_async_init()
625 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_async_callback_set() local
627 data->async_cb = callback; in uart_xmc4xxx_async_callback_set()
628 data->async_user_data = user_data; in uart_xmc4xxx_async_callback_set()
631 data->user_cb = NULL; in uart_xmc4xxx_async_callback_set()
632 data->user_data = NULL; in uart_xmc4xxx_async_callback_set()
641 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_async_tx() local
647 if (data->dma_tx.dma_dev == NULL) { in uart_xmc4xxx_async_tx()
657 if (data->dma_tx.buffer_len != 0) { in uart_xmc4xxx_async_tx()
661 data->dma_tx.buffer = (uint8_t *)tx_data; in uart_xmc4xxx_async_tx()
662 data->dma_tx.buffer_len = buf_size; in uart_xmc4xxx_async_tx()
663 data->dma_tx.timeout = timeout; in uart_xmc4xxx_async_tx()
666 data->dma_tx.blk_cfg.source_address = (uint32_t)data->dma_tx.buffer; in uart_xmc4xxx_async_tx()
667 data->dma_tx.blk_cfg.block_size = data->dma_tx.buffer_len; in uart_xmc4xxx_async_tx()
669 ret = dma_config(data->dma_tx.dma_dev, data->dma_tx.dma_channel, &data->dma_tx.dma_cfg); in uart_xmc4xxx_async_tx()
681 XMC_USIC_CH_TriggerServiceRequest(config->uart, data->service_request_tx); in uart_xmc4xxx_async_tx()
683 async_timer_start(&data->dma_tx.timeout_work, data->dma_tx.timeout); in uart_xmc4xxx_async_tx()
685 return dma_start(data->dma_tx.dma_dev, data->dma_tx.dma_channel); in uart_xmc4xxx_async_tx()
691 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_async_rx_enable() local
694 if (data->dma_rx.dma_dev == NULL) { in uart_xmc4xxx_async_rx_enable()
698 if (data->dma_rx.buffer_len != 0) { in uart_xmc4xxx_async_rx_enable()
704 data->dma_rx.buffer = buf; in uart_xmc4xxx_async_rx_enable()
705 data->dma_rx.buffer_len = len; in uart_xmc4xxx_async_rx_enable()
706 data->dma_rx.timeout = timeout; in uart_xmc4xxx_async_rx_enable()
708 data->dma_rx.blk_cfg.dest_address = (uint32_t)data->dma_rx.buffer; in uart_xmc4xxx_async_rx_enable()
709 data->dma_rx.blk_cfg.block_size = data->dma_rx.buffer_len; in uart_xmc4xxx_async_rx_enable()
711 ret = dma_config(data->dma_rx.dma_dev, data->dma_rx.dma_channel, &data->dma_rx.dma_cfg); in uart_xmc4xxx_async_rx_enable()
718 async_evt_rx_buf_request(data); in uart_xmc4xxx_async_rx_enable()
721 return dma_start(data->dma_rx.dma_dev, data->dma_rx.dma_channel); in uart_xmc4xxx_async_rx_enable()
728 struct uart_xmc4xxx_data *data = dev_uart->data; in uart_xmc4xxx_dma_rx_cb() local
732 __ASSERT_NO_MSG(channel == data->dma_rx.dma_channel); in uart_xmc4xxx_dma_rx_cb()
734 k_work_cancel_delayable(&data->dma_rx.timeout_work); in uart_xmc4xxx_dma_rx_cb()
737 async_evt_rx_stopped(data, UART_ERROR_OVERRUN); in uart_xmc4xxx_dma_rx_cb()
739 dma_stop(data->dma_rx.dma_dev, data->dma_rx.dma_channel); in uart_xmc4xxx_dma_rx_cb()
740 async_evt_rx_release_buffer(data, CURRENT_BUFFER); in uart_xmc4xxx_dma_rx_cb()
741 async_evt_rx_release_buffer(data, NEXT_BUFFER); in uart_xmc4xxx_dma_rx_cb()
742 async_evt_rx_disabled(data); in uart_xmc4xxx_dma_rx_cb()
746 if (data->dma_rx.buffer_len == 0) { in uart_xmc4xxx_dma_rx_cb()
750 data->dma_rx.counter = data->dma_rx.buffer_len; in uart_xmc4xxx_dma_rx_cb()
751 async_evt_rx_rdy(data); in uart_xmc4xxx_dma_rx_cb()
753 async_evt_rx_release_buffer(data, CURRENT_BUFFER); in uart_xmc4xxx_dma_rx_cb()
755 if (!data->rx_next_buffer) { in uart_xmc4xxx_dma_rx_cb()
757 dma_stop(data->dma_rx.dma_dev, data->dma_rx.dma_channel); in uart_xmc4xxx_dma_rx_cb()
758 async_evt_rx_disabled(data); in uart_xmc4xxx_dma_rx_cb()
762 data->dma_rx.buffer = data->rx_next_buffer; in uart_xmc4xxx_dma_rx_cb()
763 data->dma_rx.buffer_len = data->rx_next_buffer_len; in uart_xmc4xxx_dma_rx_cb()
764 data->dma_rx.offset = 0; in uart_xmc4xxx_dma_rx_cb()
765 data->dma_rx.counter = 0; in uart_xmc4xxx_dma_rx_cb()
766 data->rx_next_buffer = NULL; in uart_xmc4xxx_dma_rx_cb()
767 data->rx_next_buffer_len = 0; in uart_xmc4xxx_dma_rx_cb()
769 ret = dma_reload(data->dma_rx.dma_dev, data->dma_rx.dma_channel, in uart_xmc4xxx_dma_rx_cb()
770 data->dma_rx.blk_cfg.source_address, (uint32_t)data->dma_rx.buffer, in uart_xmc4xxx_dma_rx_cb()
771 data->dma_rx.buffer_len); in uart_xmc4xxx_dma_rx_cb()
775 dma_stop(data->dma_rx.dma_dev, data->dma_rx.dma_channel); in uart_xmc4xxx_dma_rx_cb()
776 async_evt_rx_release_buffer(data, CURRENT_BUFFER); in uart_xmc4xxx_dma_rx_cb()
777 async_evt_rx_disabled(data); in uart_xmc4xxx_dma_rx_cb()
781 dma_start(data->dma_rx.dma_dev, data->dma_rx.dma_channel); in uart_xmc4xxx_dma_rx_cb()
783 async_evt_rx_buf_request(data); in uart_xmc4xxx_dma_rx_cb()
784 async_timer_start(&data->dma_rx.timeout_work, data->dma_rx.timeout); in uart_xmc4xxx_dma_rx_cb()
791 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_async_rx_disable() local
795 k_work_cancel_delayable(&data->dma_rx.timeout_work); in uart_xmc4xxx_async_rx_disable()
799 if (data->dma_rx.buffer_len == 0) { in uart_xmc4xxx_async_rx_disable()
800 __ASSERT_NO_MSG(data->dma_rx.buffer == NULL); in uart_xmc4xxx_async_rx_disable()
805 dma_stop(data->dma_rx.dma_dev, data->dma_rx.dma_channel); in uart_xmc4xxx_async_rx_disable()
808 if (dma_get_status(data->dma_rx.dma_dev, data->dma_rx.dma_channel, &stat) == 0) { in uart_xmc4xxx_async_rx_disable()
809 size_t rx_rcv_len = data->dma_rx.buffer_len - stat.pending_length; in uart_xmc4xxx_async_rx_disable()
811 if (rx_rcv_len > data->dma_rx.offset) { in uart_xmc4xxx_async_rx_disable()
812 data->dma_rx.counter = rx_rcv_len; in uart_xmc4xxx_async_rx_disable()
813 async_evt_rx_rdy(data); in uart_xmc4xxx_async_rx_disable()
817 async_evt_rx_release_buffer(data, CURRENT_BUFFER); in uart_xmc4xxx_async_rx_disable()
818 async_evt_rx_release_buffer(data, NEXT_BUFFER); in uart_xmc4xxx_async_rx_disable()
819 async_evt_rx_disabled(data); in uart_xmc4xxx_async_rx_disable()
830 struct uart_xmc4xxx_data *data = dev_uart->data; in uart_xmc4xxx_dma_tx_cb() local
831 size_t tx_buffer_len = data->dma_tx.buffer_len; in uart_xmc4xxx_dma_tx_cb()
838 __ASSERT_NO_MSG(channel == data->dma_tx.dma_channel); in uart_xmc4xxx_dma_tx_cb()
840 k_work_cancel_delayable(&data->dma_tx.timeout_work); in uart_xmc4xxx_dma_tx_cb()
846 if (!dma_get_status(data->dma_tx.dma_dev, channel, &stat)) { in uart_xmc4xxx_dma_tx_cb()
847 data->dma_tx.counter = tx_buffer_len - stat.pending_length; in uart_xmc4xxx_dma_tx_cb()
850 async_evt_tx_done(data); in uart_xmc4xxx_dma_tx_cb()
852 if (data->dma_tx.buffer == NULL) { in uart_xmc4xxx_dma_tx_cb()
853 dma_stop(data->dma_tx.dma_dev, data->dma_tx.dma_channel); in uart_xmc4xxx_dma_tx_cb()
860 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_rx_buf_rsp() local
866 if (data->dma_rx.buffer_len == 0U) { in uart_xmc4xxx_rx_buf_rsp()
871 if (data->rx_next_buffer_len != 0U) { in uart_xmc4xxx_rx_buf_rsp()
876 data->rx_next_buffer = buf; in uart_xmc4xxx_rx_buf_rsp()
877 data->rx_next_buffer_len = len; in uart_xmc4xxx_rx_buf_rsp()
890 struct uart_xmc4xxx_data *data = dev->data; in uart_xmc4xxx_init() local
893 data->config.data_bits = 8U; in uart_xmc4xxx_init()
894 data->config.stop_bits = 1U; in uart_xmc4xxx_init()
896 XMC_UART_CH_Init(config->uart, &(data->config)); in uart_xmc4xxx_init()