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

serial: 8250: move RSA functions to 8250_rsa.c

They are RSA-specific, so should live in a preexisting 8250_rsa.c. Move
them there.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250611100319.186924-13-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
5a128fb4 8725679f

+100 -99
+8
drivers/tty/serial/8250/8250.h
··· 318 318 319 319 #ifdef CONFIG_SERIAL_8250_RSA 320 320 void univ8250_rsa_support(struct uart_ops *ops); 321 + void rsa_enable(struct uart_8250_port *up); 322 + void rsa_disable(struct uart_8250_port *up); 323 + void rsa_autoconfig(struct uart_8250_port *up); 324 + void rsa_reset(struct uart_8250_port *up); 321 325 #else 322 326 static inline void univ8250_rsa_support(struct uart_ops *ops) { } 327 + static inline void rsa_enable(struct uart_8250_port *up) {} 328 + static inline void rsa_disable(struct uart_8250_port *up) {} 329 + static inline void rsa_autoconfig(struct uart_8250_port *up) {} 330 + static inline void rsa_reset(struct uart_8250_port *up) {} 323 331 #endif 324 332 325 333 #ifdef CONFIG_SERIAL_8250_FINTEK
-99
drivers/tty/serial/8250/8250_port.c
··· 713 713 serial_out(up, UART_IER, 0); 714 714 } 715 715 716 - #ifdef CONFIG_SERIAL_8250_RSA 717 - /* 718 - * Attempts to turn on the RSA FIFO. Returns zero on failure. 719 - * We set the port uart clock rate if we succeed. 720 - */ 721 - static int __rsa_enable(struct uart_8250_port *up) 722 - { 723 - unsigned char mode; 724 - int result; 725 - 726 - mode = serial_in(up, UART_RSA_MSR); 727 - result = mode & UART_RSA_MSR_FIFO; 728 - 729 - if (!result) { 730 - serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); 731 - mode = serial_in(up, UART_RSA_MSR); 732 - result = mode & UART_RSA_MSR_FIFO; 733 - } 734 - 735 - if (result) 736 - up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; 737 - 738 - return result; 739 - } 740 - 741 - /* 742 - * If this is an RSA port, see if we can kick it up to the higher speed clock. 743 - */ 744 - static void rsa_enable(struct uart_8250_port *up) 745 - { 746 - if (up->port.type != PORT_RSA) 747 - return; 748 - 749 - if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) { 750 - uart_port_lock_irq(&up->port); 751 - __rsa_enable(up); 752 - uart_port_unlock_irq(&up->port); 753 - } 754 - if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) 755 - serial_out(up, UART_RSA_FRR, 0); 756 - } 757 - 758 - /* 759 - * Attempts to turn off the RSA FIFO and resets the RSA board back to 115kbps compat mode. It is 760 - * unknown why interrupts were disabled in here. However, the caller is expected to preserve this 761 - * behaviour by grabbing the spinlock before calling this function. 762 - */ 763 - static void rsa_disable(struct uart_8250_port *up) 764 - { 765 - unsigned char mode; 766 - int result; 767 - 768 - if (up->port.type != PORT_RSA) 769 - return; 770 - 771 - if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) 772 - return; 773 - 774 - uart_port_lock_irq(&up->port); 775 - mode = serial_in(up, UART_RSA_MSR); 776 - result = !(mode & UART_RSA_MSR_FIFO); 777 - 778 - if (!result) { 779 - serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); 780 - mode = serial_in(up, UART_RSA_MSR); 781 - result = !(mode & UART_RSA_MSR_FIFO); 782 - } 783 - 784 - if (result) 785 - up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; 786 - uart_port_unlock_irq(&up->port); 787 - } 788 - 789 - static void rsa_autoconfig(struct uart_8250_port *up) 790 - { 791 - /* Only probe for RSA ports if we got the region. */ 792 - if (up->port.type != PORT_16550A) 793 - return; 794 - if (!(up->probe & UART_PROBE_RSA)) 795 - return; 796 - 797 - if (__rsa_enable(up)) 798 - up->port.type = PORT_RSA; 799 - } 800 - 801 - static void rsa_reset(struct uart_8250_port *up) 802 - { 803 - if (up->port.type != PORT_RSA) 804 - return; 805 - 806 - serial_out(up, UART_RSA_FRR, 0); 807 - } 808 - #else 809 - static inline void rsa_enable(struct uart_8250_port *up) {} 810 - static inline void rsa_disable(struct uart_8250_port *up) {} 811 - static inline void rsa_autoconfig(struct uart_8250_port *up) {} 812 - static inline void rsa_reset(struct uart_8250_port *up) {} 813 - #endif /* CONFIG_SERIAL_8250_RSA */ 814 - 815 716 /* 816 717 * This is a quickie test to see how big the FIFO is. 817 718 * It doesn't work at all the time, more's the pity.
+92
drivers/tty/serial/8250/8250_rsa.c
··· 107 107 module_param_hw_array(probe_rsa, ulong, ioport, &probe_rsa_count, 0444); 108 108 MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); 109 109 110 + /* 111 + * Attempts to turn on the RSA FIFO. Returns zero on failure. 112 + * We set the port uart clock rate if we succeed. 113 + */ 114 + static int __rsa_enable(struct uart_8250_port *up) 115 + { 116 + unsigned char mode; 117 + int result; 118 + 119 + mode = serial_in(up, UART_RSA_MSR); 120 + result = mode & UART_RSA_MSR_FIFO; 121 + 122 + if (!result) { 123 + serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); 124 + mode = serial_in(up, UART_RSA_MSR); 125 + result = mode & UART_RSA_MSR_FIFO; 126 + } 127 + 128 + if (result) 129 + up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16; 130 + 131 + return result; 132 + } 133 + 134 + /* 135 + * If this is an RSA port, see if we can kick it up to the higher speed clock. 136 + */ 137 + void rsa_enable(struct uart_8250_port *up) 138 + { 139 + if (up->port.type != PORT_RSA) 140 + return; 141 + 142 + if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) { 143 + uart_port_lock_irq(&up->port); 144 + __rsa_enable(up); 145 + uart_port_unlock_irq(&up->port); 146 + } 147 + if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) 148 + serial_out(up, UART_RSA_FRR, 0); 149 + } 150 + 151 + /* 152 + * Attempts to turn off the RSA FIFO and resets the RSA board back to 115kbps compat mode. It is 153 + * unknown why interrupts were disabled in here. However, the caller is expected to preserve this 154 + * behaviour by grabbing the spinlock before calling this function. 155 + */ 156 + void rsa_disable(struct uart_8250_port *up) 157 + { 158 + unsigned char mode; 159 + int result; 160 + 161 + if (up->port.type != PORT_RSA) 162 + return; 163 + 164 + if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) 165 + return; 166 + 167 + uart_port_lock_irq(&up->port); 168 + mode = serial_in(up, UART_RSA_MSR); 169 + result = !(mode & UART_RSA_MSR_FIFO); 170 + 171 + if (!result) { 172 + serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); 173 + mode = serial_in(up, UART_RSA_MSR); 174 + result = !(mode & UART_RSA_MSR_FIFO); 175 + } 176 + 177 + if (result) 178 + up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16; 179 + uart_port_unlock_irq(&up->port); 180 + } 181 + 182 + void rsa_autoconfig(struct uart_8250_port *up) 183 + { 184 + /* Only probe for RSA ports if we got the region. */ 185 + if (up->port.type != PORT_16550A) 186 + return; 187 + if (!(up->probe & UART_PROBE_RSA)) 188 + return; 189 + 190 + if (__rsa_enable(up)) 191 + up->port.type = PORT_RSA; 192 + } 193 + 194 + void rsa_reset(struct uart_8250_port *up) 195 + { 196 + if (up->port.type != PORT_RSA) 197 + return; 198 + 199 + serial_out(up, UART_RSA_FRR, 0); 200 + } 201 + 110 202 #ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS 111 203 #ifndef MODULE 112 204 /*