Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: ar933x: Add polling support

KGDB requires at least the polling hooks .poll_get_char and .poll_put_char
to transmit/receive character via the serial driver.

Signed-off-by: Sven Eckelmann <se@simonwunderlich.de>
Link: https://patch.msgid.link/20251001-ar933x-kgdb-support-v1-1-5fffd9e36a01@simonwunderlich.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sven Eckelmann and committed by
Greg Kroah-Hartman
08a0dd5a fd3d4f5a

+62
+62
drivers/tty/serial/ar933x_uart.c
··· 560 560 return 0; 561 561 } 562 562 563 + #ifdef CONFIG_CONSOLE_POLL 564 + static int ar933x_poll_get_char(struct uart_port *port) 565 + { 566 + struct ar933x_uart_port *up = 567 + container_of(port, struct ar933x_uart_port, port); 568 + unsigned int rdata; 569 + unsigned char ch; 570 + u32 imr; 571 + 572 + /* Disable all interrupts */ 573 + imr = ar933x_uart_read(up, AR933X_UART_INT_EN_REG); 574 + ar933x_uart_write(up, AR933X_UART_INT_EN_REG, 0); 575 + 576 + rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG); 577 + if ((rdata & AR933X_UART_DATA_RX_CSR) == 0) { 578 + /* Enable interrupts */ 579 + ar933x_uart_write(up, AR933X_UART_INT_EN_REG, imr); 580 + return NO_POLL_CHAR; 581 + } 582 + 583 + /* remove the character from the FIFO */ 584 + ar933x_uart_write(up, AR933X_UART_DATA_REG, 585 + AR933X_UART_DATA_RX_CSR); 586 + 587 + ch = rdata & AR933X_UART_DATA_TX_RX_MASK; 588 + 589 + /* Enable interrupts */ 590 + ar933x_uart_write(up, AR933X_UART_INT_EN_REG, imr); 591 + 592 + return ch; 593 + } 594 + 595 + static void ar933x_poll_put_char(struct uart_port *port, unsigned char c) 596 + { 597 + struct ar933x_uart_port *up = 598 + container_of(port, struct ar933x_uart_port, port); 599 + u32 imr; 600 + 601 + /* Disable all interrupts */ 602 + imr = ar933x_uart_read(up, AR933X_UART_INT_EN_REG); 603 + ar933x_uart_write(up, AR933X_UART_INT_EN_REG, 0); 604 + 605 + /* Wait until FIFO is empty */ 606 + while (!(ar933x_uart_read(up, AR933X_UART_DATA_REG) & AR933X_UART_DATA_TX_CSR)) 607 + cpu_relax(); 608 + 609 + /* Write a character */ 610 + ar933x_uart_putc(up, c); 611 + 612 + /* Wait until FIFO is empty */ 613 + while (!(ar933x_uart_read(up, AR933X_UART_DATA_REG) & AR933X_UART_DATA_TX_CSR)) 614 + cpu_relax(); 615 + 616 + /* Enable interrupts */ 617 + ar933x_uart_write(up, AR933X_UART_INT_EN_REG, imr); 618 + } 619 + #endif 620 + 563 621 static const struct uart_ops ar933x_uart_ops = { 564 622 .tx_empty = ar933x_uart_tx_empty, 565 623 .set_mctrl = ar933x_uart_set_mctrl, ··· 634 576 .request_port = ar933x_uart_request_port, 635 577 .config_port = ar933x_uart_config_port, 636 578 .verify_port = ar933x_uart_verify_port, 579 + #ifdef CONFIG_CONSOLE_POLL 580 + .poll_get_char = ar933x_poll_get_char, 581 + .poll_put_char = ar933x_poll_put_char, 582 + #endif 637 583 }; 638 584 639 585 static int ar933x_config_rs485(struct uart_port *port, struct ktermios *termios,