stm32-usart.c (4f01d833fdcdd6f9b85d9e5d5d7568eb683626a7) stm32-usart.c (6c5962f30bce147b1c83869085f3ddde3b34c9e3)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) Maxime Coquelin 2015
4 * Copyright (C) STMicroelectronics SA 2017
5 * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com>
6 * Gerald Baeza <gerald.baeza@st.com>
7 *
8 * Inspired by st-asc.c from STMicroelectronics (c)

--- 180 unchanged lines hidden (view full) ---

189 else
190 return 0;
191 } else if (*sr & USART_SR_RXNE) {
192 return 1;
193 }
194 return 0;
195}
196
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) Maxime Coquelin 2015
4 * Copyright (C) STMicroelectronics SA 2017
5 * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com>
6 * Gerald Baeza <gerald.baeza@st.com>
7 *
8 * Inspired by st-asc.c from STMicroelectronics (c)

--- 180 unchanged lines hidden (view full) ---

189 else
190 return 0;
191 } else if (*sr & USART_SR_RXNE) {
192 return 1;
193 }
194 return 0;
195}
196
197static unsigned long
198stm32_get_char(struct uart_port *port, u32 *sr, int *last_res)
197static unsigned long stm32_get_char(struct uart_port *port, u32 *sr,
198 int *last_res)
199{
200 struct stm32_port *stm32_port = to_stm32_port(port);
201 struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
202 unsigned long c;
203
204 if (stm32_port->rx_ch) {
205 c = stm32_port->rx_buf[RX_BUF_L - (*last_res)--];
206 if ((*last_res) == 0)
207 *last_res = RX_BUF_L;
199{
200 struct stm32_port *stm32_port = to_stm32_port(port);
201 struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
202 unsigned long c;
203
204 if (stm32_port->rx_ch) {
205 c = stm32_port->rx_buf[RX_BUF_L - (*last_res)--];
206 if ((*last_res) == 0)
207 *last_res = RX_BUF_L;
208 return c;
209 } else {
208 } else {
210 return readl_relaxed(port->membase + ofs->rdr);
209 c = readl_relaxed(port->membase + ofs->rdr);
210 /* apply RDR data mask */
211 c &= stm32_port->rdr_mask;
211 }
212 }
213
214 return c;
212}
213
214static void stm32_receive_chars(struct uart_port *port, bool threaded)
215{
216 struct tty_port *tport = &port->state->port;
217 struct stm32_port *stm32_port = to_stm32_port(port);
218 struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
219 unsigned long c;

--- 454 unchanged lines hidden (view full) ---

674 cr1 |= USART_CR1_FIFOEN;
675 cr2 = 0;
676 cr3 = 0;
677
678 if (cflag & CSTOPB)
679 cr2 |= USART_CR2_STOP_2B;
680
681 bits = stm32_get_databits(termios);
215}
216
217static void stm32_receive_chars(struct uart_port *port, bool threaded)
218{
219 struct tty_port *tport = &port->state->port;
220 struct stm32_port *stm32_port = to_stm32_port(port);
221 struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
222 unsigned long c;

--- 454 unchanged lines hidden (view full) ---

677 cr1 |= USART_CR1_FIFOEN;
678 cr2 = 0;
679 cr3 = 0;
680
681 if (cflag & CSTOPB)
682 cr2 |= USART_CR2_STOP_2B;
683
684 bits = stm32_get_databits(termios);
685 stm32_port->rdr_mask = (BIT(bits) - 1);
682
683 if (cflag & PARENB) {
684 bits++;
685 cr1 |= USART_CR1_PCE;
686 }
687
688 /*
689 * Word length configuration:

--- 652 unchanged lines hidden ---
686
687 if (cflag & PARENB) {
688 bits++;
689 cr1 |= USART_CR1_PCE;
690 }
691
692 /*
693 * Word length configuration:

--- 652 unchanged lines hidden ---