From: Miroslav Ondra Date: Wed, 22 Jan 2020 21:02:32 +0000 (+0100) Subject: Add flush_buffer to uart X-Git-Url: http://git.graph-it.com/?a=commitdiff_plain;h=5c7c7d03f3ecda1d8539534e81879df153e8071d;p=graphit%2Funipi-kernel.git Add flush_buffer to uart --- diff --git a/modules/unipi/src/unipi_spi.c b/modules/unipi/src/unipi_spi.c index 6fa32e3..851c7dd 100644 --- a/modules/unipi/src/unipi_spi.c +++ b/modules/unipi/src/unipi_spi.c @@ -1117,6 +1117,27 @@ void neuronspi_spi_set_irqs(struct spi_device* spi_dev, u16 to) unipi_spi_trace(KERN_INFO "UNIPISPI: SPI IRQ Set, CS%d, to:0x%x\n", spi_dev->chip_select, to); } +void neuronspi_uart_flush_proc(struct kthread_work *ws) +{ + struct neuronspi_port *n_port = ((container_of((ws), struct neuronspi_port, flush_work))); + struct spi_device *spi = neuronspi_s_dev[n_spi->neuron_index]; + struct neuronspi_op_buffer recv_buf; + unsigned long flags; + + unipi_spi_read_str(spi, n_port); + if (n_port->rx_in_progress) { + s32 frequency = NEURONSPI_DEFAULT_FREQ; + if (n_spi) { + frequency = n_spi->ideal_frequency; + } + neuronspi_spi_send_const_op(spi, &UNIPISPI_IDLE_MESSAGE, &recv_buf, 0, frequency, 25); + } + + spin_lock_irqsave(&n_port->port.lock, flags); + n_port->accept_rx = 1; + spin_lock_irqrestore(&n_port->port.lock, flags); + +} void neuronspi_irq_proc(struct kthread_work *ws) { diff --git a/modules/unipi/src/unipi_spi.h b/modules/unipi/src/unipi_spi.h index 8dcae85..1de5252 100644 --- a/modules/unipi/src/unipi_spi.h +++ b/modules/unipi/src/unipi_spi.h @@ -128,7 +128,7 @@ int unipi_spi_write_str(struct spi_device* spi, struct neuronspi_port* port, int int unipi_spi_get_tx_fifo(struct spi_device* spi, struct neuronspi_port* port); void neuronspi_enable_uart_interrupt(struct neuronspi_port* n_port); - +void neuronspi_uart_flush_proc(struct kthread_work *ws); /*********************** * Function structures * diff --git a/modules/unipi/src/unipi_uart.c b/modules/unipi/src/unipi_uart.c index 7837586..02fa7e6 100644 --- a/modules/unipi/src/unipi_uart.c +++ b/modules/unipi/src/unipi_uart.c @@ -154,27 +154,6 @@ void neuronspi_uart_set_ldisc(struct uart_port *port, struct ktermios *kterm) } -void neuronspi_uart_flush_proc(struct kthread_work *ws) -{ - struct neuronspi_port *n_port = ((container_of((ws), struct neuronspi_port, flush_work))); - struct spi_device *spi = neuronspi_s_dev[n_spi->neuron_index]; - struct neuronspi_op_buffer recv_buf; - unsigned long flags; - - unipi_spi_read_str(spi, n_port); - if (n_port->rx_in_progress) { - s32 frequency = NEURONSPI_DEFAULT_FREQ; - if (n_spi) { - frequency = n_spi->ideal_frequency; - } - neuronspi_spi_send_const_op(spi, &UNIPISPI_IDLE_MESSAGE, &recv_buf, 0, frequency, 25); - } - - spin_lock_irqsave(&port->port.lock, flags); - n_port->accept_rx = 1; - spin_lock_irqrestore(&port->port.lock, flags); - -} void neuronspi_uart_flush_buffer(struct uart_port* port)