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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'tty-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty / serial updates from Greg KH:
"Here is a small set of tty and serial driver updates for 6.11-rc1. Not
much happened this cycle, unlike the previous kernel release which had
lots of "excitement" in this part of the kernel. Included in here are
the following changes:

- dt binding updates for new platforms

- 8250 driver updates

- various small serial driver fixes and updates

- printk/console naming and matching attempt #2 (was reverted for
6.10-final, should be good to go this time around, acked by the
relevant maintainers).

All of these have been in linux-next for a while with no reported
issues"

* tag 'tty-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (22 commits)
Documentation: kernel-parameters: Add DEVNAME:0.0 format for serial ports
serial: core: Add serial_base_match_and_update_preferred_console()
printk: Add match_devname_and_update_preferred_console()
serial: sc16is7xx: hardware reset chip if reset-gpios is defined in DT
dt-bindings: serial: sc16is7xx: add reset-gpios
dt-bindings: serial: vt8500-uart: convert to json-schema
serial: 8250_platform: Explicitly show we initialise ISA ports only once
tty: add missing MODULE_DESCRIPTION() macros
dt-bindings: serial: mediatek,uart: add MT7988
serial: sh-sci: Add support for RZ/V2H(P) SoC
dt-bindings: serial: Add documentation for Renesas RZ/V2H(P) (R9A09G057) SCIF support
dt-bindings: serial: renesas,scif: Make 'interrupt-names' property as required
dt-bindings: serial: renesas,scif: Validate 'interrupts' and 'interrupt-names'
dt-bindings: serial: renesas,scif: Move ref for serial.yaml at the end
riscv: dts: starfive: jh7110: Add the core reset and jh7110 compatible for uarts
serial: 8250_dw: Use reset array API to get resets
dt-bindings: serial: snps-dw-apb-uart: Add one more reset signal for StarFive JH7110 SoC
serial: 8250: Extract platform driver
serial: 8250: Extract RSA bits
serial: imx: stop casting struct uart_port to struct imx_port
...

+1000 -598
+19
Documentation/admin-guide/kernel-parameters.txt
··· 792 792 Documentation/networking/netconsole.rst for an 793 793 alternative. 794 794 795 + <DEVNAME>:<n>.<n>[,options] 796 + Use the specified serial port on the serial core bus. 797 + The addressing uses DEVNAME of the physical serial port 798 + device, followed by the serial core controller instance, 799 + and the serial port instance. The options are the same 800 + as documented for the ttyS addressing above. 801 + 802 + The mapping of the serial ports to the tty instances 803 + can be viewed with: 804 + 805 + $ ls -d /sys/bus/serial-base/devices/*:*.*/tty/* 806 + /sys/bus/serial-base/devices/00:04:0.0/tty/ttyS0 807 + 808 + In the above example, the console can be addressed with 809 + console=00:04:0.0. Note that a console addressed this 810 + way will only get added when the related device driver 811 + is ready. The use of an earlycon parameter in addition to 812 + the console may be desired for console output early on. 813 + 795 814 uart[8250],io,<addr>[,options] 796 815 uart[8250],mmio,<addr>[,options] 797 816 uart[8250],mmio16,<addr>[,options]
+1
Documentation/devicetree/bindings/serial/mediatek,uart.yaml
··· 37 37 - mediatek,mt7623-uart 38 38 - mediatek,mt7629-uart 39 39 - mediatek,mt7986-uart 40 + - mediatek,mt7988-uart 40 41 - mediatek,mt8127-uart 41 42 - mediatek,mt8135-uart 42 43 - mediatek,mt8173-uart
+5
Documentation/devicetree/bindings/serial/nxp,sc16is7xx.yaml
··· 28 28 clocks: 29 29 maxItems: 1 30 30 31 + reset-gpios: 32 + maxItems: 1 33 + 31 34 clock-frequency: 32 35 description: 33 36 When there is no clock provider visible to the platform, this ··· 94 91 examples: 95 92 - | 96 93 #include <dt-bindings/interrupt-controller/irq.h> 94 + #include <dt-bindings/gpio/gpio.h> 97 95 i2c { 98 96 #address-cells = <1>; 99 97 #size-cells = <0>; ··· 124 120 compatible = "nxp,sc16is752"; 125 121 reg = <0x54>; 126 122 clocks = <&clk20m>; 123 + reset-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>; 127 124 interrupt-parent = <&gpio3>; 128 125 interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 129 126 nxp,modem-control-line-ports = <0 1>; /* Ports 0 and 1 as modem control lines */
+103 -33
Documentation/devicetree/bindings/serial/renesas,scif.yaml
··· 9 9 maintainers: 10 10 - Geert Uytterhoeven <geert+renesas@glider.be> 11 11 12 - allOf: 13 - - $ref: serial.yaml# 14 - 15 12 properties: 16 13 compatible: 17 14 oneOf: ··· 80 83 - renesas,scif-r9a08g045 # RZ/G3S 81 84 - const: renesas,scif-r9a07g044 # RZ/G2{L,LC} fallback 82 85 86 + - const: renesas,scif-r9a09g057 # RZ/V2H(P) 87 + 83 88 reg: 84 89 maxItems: 1 85 90 ··· 94 95 - description: Receive buffer full interrupt 95 96 - description: Transmit buffer empty interrupt 96 97 - description: Break interrupt 97 - - items: 98 - - description: Error interrupt 99 - - description: Receive buffer full interrupt 100 - - description: Transmit buffer empty interrupt 101 - - description: Break interrupt 102 98 - description: Data Ready interrupt 103 99 - description: Transmit End interrupt 100 + - description: Transmit End/Data Ready interrupt 101 + - description: Receive buffer full interrupt (EDGE trigger) 102 + - description: Transmit buffer empty interrupt (EDGE trigger) 103 + minItems: 4 104 104 105 105 interrupt-names: 106 - oneOf: 107 - - items: 108 - - const: eri 109 - - const: rxi 110 - - const: txi 111 - - const: bri 112 - - items: 113 - - const: eri 114 - - const: rxi 115 - - const: txi 116 - - const: bri 117 - - const: dri 118 - - const: tei 106 + minItems: 4 107 + items: 108 + - const: eri 109 + - const: rxi 110 + - const: txi 111 + - const: bri 112 + - const: dri 113 + - const: tei 114 + - const: tei-dri 115 + - const: rxi-edge 116 + - const: txi-edge 119 117 120 118 clocks: 121 119 minItems: 1 ··· 157 161 - clock-names 158 162 - power-domains 159 163 160 - if: 161 - properties: 162 - compatible: 163 - contains: 164 - enum: 165 - - renesas,rcar-gen2-scif 166 - - renesas,rcar-gen3-scif 167 - - renesas,rcar-gen4-scif 168 - - renesas,scif-r9a07g044 169 - then: 170 - required: 171 - - resets 164 + allOf: 165 + - $ref: serial.yaml# 166 + 167 + - if: 168 + properties: 169 + compatible: 170 + contains: 171 + enum: 172 + - renesas,rcar-gen2-scif 173 + - renesas,rcar-gen3-scif 174 + - renesas,rcar-gen4-scif 175 + - renesas,scif-r9a07g044 176 + - renesas,scif-r9a09g057 177 + then: 178 + required: 179 + - resets 180 + 181 + - if: 182 + properties: 183 + compatible: 184 + contains: 185 + enum: 186 + - renesas,rcar-gen1-scif 187 + - renesas,rcar-gen2-scif 188 + - renesas,rcar-gen3-scif 189 + - renesas,rcar-gen4-scif 190 + then: 191 + properties: 192 + interrupts: 193 + maxItems: 1 194 + 195 + interrupt-names: false 196 + else: 197 + required: 198 + - interrupt-names 199 + 200 + - if: 201 + properties: 202 + compatible: 203 + contains: 204 + enum: 205 + - renesas,scif-r7s72100 206 + then: 207 + properties: 208 + interrupts: 209 + minItems: 4 210 + maxItems: 4 211 + 212 + interrupt-names: 213 + maxItems: 4 214 + 215 + - if: 216 + properties: 217 + compatible: 218 + contains: 219 + enum: 220 + - renesas,scif-r7s9210 221 + - renesas,scif-r9a07g044 222 + then: 223 + properties: 224 + interrupts: 225 + minItems: 6 226 + maxItems: 6 227 + 228 + interrupt-names: 229 + minItems: 6 230 + maxItems: 6 231 + 232 + - if: 233 + properties: 234 + compatible: 235 + contains: 236 + const: renesas,scif-r9a09g057 237 + then: 238 + properties: 239 + clocks: 240 + maxItems: 1 241 + 242 + clock-names: 243 + maxItems: 1 244 + 245 + interrupts: 246 + minItems: 9 247 + 248 + interrupt-names: 249 + minItems: 9 172 250 173 251 unevaluatedProperties: false 174 252
+17 -1
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
··· 13 13 - $ref: serial.yaml# 14 14 - $ref: rs485.yaml# 15 15 16 + - if: 17 + properties: 18 + compatible: 19 + contains: 20 + const: starfive,jh7110-uart 21 + then: 22 + properties: 23 + resets: 24 + minItems: 2 25 + else: 26 + properties: 27 + resets: 28 + maxItems: 1 29 + 16 30 properties: 17 31 compatible: 18 32 oneOf: ··· 62 48 - enum: 63 49 - starfive,jh7100-hsuart 64 50 - starfive,jh7100-uart 51 + - starfive,jh7110-uart 65 52 - const: snps,dw-apb-uart 66 53 - const: snps,dw-apb-uart 67 54 ··· 97 82 type: boolean 98 83 99 84 resets: 100 - maxItems: 1 85 + minItems: 1 86 + maxItems: 2 101 87 102 88 reg-shift: true 103 89
+46
Documentation/devicetree/bindings/serial/via,vt8500-uart.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + 3 + %YAML 1.2 4 + --- 5 + $id: http://devicetree.org/schemas/serial/via,vt8500-uart.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: VIA VT8500 and WonderMedia WM8xxx UART Controller 9 + 10 + maintainers: 11 + - Alexey Charkov <alchark@gmail.com> 12 + 13 + allOf: 14 + - $ref: serial.yaml 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - via,vt8500-uart # up to WM8850/WM8950 20 + - wm,wm8880-uart # for WM8880 and later 21 + 22 + clocks: 23 + maxItems: 1 24 + 25 + interrupts: 26 + maxItems: 1 27 + 28 + reg: 29 + maxItems: 1 30 + 31 + required: 32 + - compatible 33 + - clocks 34 + - interrupts 35 + - reg 36 + 37 + unevaluatedProperties: false 38 + 39 + examples: 40 + - | 41 + serial@d8200000 { 42 + compatible = "via,vt8500-uart"; 43 + reg = <0xd8200000 0x1040>; 44 + interrupts = <32>; 45 + clocks = <&clkuart0>; 46 + };
-27
Documentation/devicetree/bindings/serial/vt8500-uart.txt
··· 1 - * VIA VT8500 and WonderMedia WM8xxx UART Controller 2 - 3 - Required properties: 4 - - compatible: should be "via,vt8500-uart" (for VIA/WonderMedia chips up to and 5 - including WM8850/WM8950), or "wm,wm8880-uart" (for WM8880 and later) 6 - 7 - - reg: base physical address of the controller and length of memory mapped 8 - region. 9 - 10 - - interrupts: hardware interrupt number 11 - 12 - - clocks: shall be the input parent clock phandle for the clock. This should 13 - be the 24Mhz reference clock. 14 - 15 - Aliases may be defined to ensure the correct ordering of the uarts. 16 - 17 - Example: 18 - aliases { 19 - serial0 = &uart0; 20 - }; 21 - 22 - uart0: serial@d8200000 { 23 - compatible = "via,vt8500-uart"; 24 - reg = <0xd8200000 0x1040>; 25 - interrupts = <32>; 26 - clocks = <&clkuart0>; 27 - };
+18 -12
arch/riscv/boot/dts/starfive/jh7110.dtsi
··· 387 387 }; 388 388 389 389 uart0: serial@10000000 { 390 - compatible = "snps,dw-apb-uart"; 390 + compatible = "starfive,jh7110-uart", "snps,dw-apb-uart"; 391 391 reg = <0x0 0x10000000 0x0 0x10000>; 392 392 clocks = <&syscrg JH7110_SYSCLK_UART0_CORE>, 393 393 <&syscrg JH7110_SYSCLK_UART0_APB>; 394 394 clock-names = "baudclk", "apb_pclk"; 395 - resets = <&syscrg JH7110_SYSRST_UART0_APB>; 395 + resets = <&syscrg JH7110_SYSRST_UART0_APB>, 396 + <&syscrg JH7110_SYSRST_UART0_CORE>; 396 397 interrupts = <32>; 397 398 reg-io-width = <4>; 398 399 reg-shift = <2>; ··· 401 400 }; 402 401 403 402 uart1: serial@10010000 { 404 - compatible = "snps,dw-apb-uart"; 403 + compatible = "starfive,jh7110-uart", "snps,dw-apb-uart"; 405 404 reg = <0x0 0x10010000 0x0 0x10000>; 406 405 clocks = <&syscrg JH7110_SYSCLK_UART1_CORE>, 407 406 <&syscrg JH7110_SYSCLK_UART1_APB>; 408 407 clock-names = "baudclk", "apb_pclk"; 409 - resets = <&syscrg JH7110_SYSRST_UART1_APB>; 408 + resets = <&syscrg JH7110_SYSRST_UART1_APB>, 409 + <&syscrg JH7110_SYSRST_UART1_CORE>; 410 410 interrupts = <33>; 411 411 reg-io-width = <4>; 412 412 reg-shift = <2>; ··· 415 413 }; 416 414 417 415 uart2: serial@10020000 { 418 - compatible = "snps,dw-apb-uart"; 416 + compatible = "starfive,jh7110-uart", "snps,dw-apb-uart"; 419 417 reg = <0x0 0x10020000 0x0 0x10000>; 420 418 clocks = <&syscrg JH7110_SYSCLK_UART2_CORE>, 421 419 <&syscrg JH7110_SYSCLK_UART2_APB>; 422 420 clock-names = "baudclk", "apb_pclk"; 423 - resets = <&syscrg JH7110_SYSRST_UART2_APB>; 421 + resets = <&syscrg JH7110_SYSRST_UART2_APB>, 422 + <&syscrg JH7110_SYSRST_UART2_CORE>; 424 423 interrupts = <34>; 425 424 reg-io-width = <4>; 426 425 reg-shift = <2>; ··· 645 642 }; 646 643 647 644 uart3: serial@12000000 { 648 - compatible = "snps,dw-apb-uart"; 645 + compatible = "starfive,jh7110-uart", "snps,dw-apb-uart"; 649 646 reg = <0x0 0x12000000 0x0 0x10000>; 650 647 clocks = <&syscrg JH7110_SYSCLK_UART3_CORE>, 651 648 <&syscrg JH7110_SYSCLK_UART3_APB>; 652 649 clock-names = "baudclk", "apb_pclk"; 653 - resets = <&syscrg JH7110_SYSRST_UART3_APB>; 650 + resets = <&syscrg JH7110_SYSRST_UART3_APB>, 651 + <&syscrg JH7110_SYSRST_UART3_CORE>; 654 652 interrupts = <45>; 655 653 reg-io-width = <4>; 656 654 reg-shift = <2>; ··· 659 655 }; 660 656 661 657 uart4: serial@12010000 { 662 - compatible = "snps,dw-apb-uart"; 658 + compatible = "starfive,jh7110-uart", "snps,dw-apb-uart"; 663 659 reg = <0x0 0x12010000 0x0 0x10000>; 664 660 clocks = <&syscrg JH7110_SYSCLK_UART4_CORE>, 665 661 <&syscrg JH7110_SYSCLK_UART4_APB>; 666 662 clock-names = "baudclk", "apb_pclk"; 667 - resets = <&syscrg JH7110_SYSRST_UART4_APB>; 663 + resets = <&syscrg JH7110_SYSRST_UART4_APB>, 664 + <&syscrg JH7110_SYSRST_UART4_CORE>; 668 665 interrupts = <46>; 669 666 reg-io-width = <4>; 670 667 reg-shift = <2>; ··· 673 668 }; 674 669 675 670 uart5: serial@12020000 { 676 - compatible = "snps,dw-apb-uart"; 671 + compatible = "starfive,jh7110-uart", "snps,dw-apb-uart"; 677 672 reg = <0x0 0x12020000 0x0 0x10000>; 678 673 clocks = <&syscrg JH7110_SYSCLK_UART5_CORE>, 679 674 <&syscrg JH7110_SYSCLK_UART5_APB>; 680 675 clock-names = "baudclk", "apb_pclk"; 681 - resets = <&syscrg JH7110_SYSRST_UART5_APB>; 676 + resets = <&syscrg JH7110_SYSRST_UART5_APB>, 677 + <&syscrg JH7110_SYSRST_UART5_CORE>; 682 678 interrupts = <47>; 683 679 reg-io-width = <4>; 684 680 reg-shift = <2>;
+1
drivers/tty/amiserial.c
··· 1660 1660 1661 1661 #endif /* CONFIG_SERIAL_CONSOLE && !MODULE */ 1662 1662 1663 + MODULE_DESCRIPTION("Serial driver for the amiga builtin port"); 1663 1664 MODULE_LICENSE("GPL"); 1664 1665 MODULE_ALIAS("platform:amiga-serial");
+1
drivers/tty/goldfish.c
··· 470 470 471 471 module_platform_driver(goldfish_tty_platform_driver); 472 472 473 + MODULE_DESCRIPTION("Goldfish TTY Driver"); 473 474 MODULE_LICENSE("GPL v2");
+1
drivers/tty/n_gsm.c
··· 4634 4634 module_exit(gsm_exit); 4635 4635 4636 4636 4637 + MODULE_DESCRIPTION("GSM 0710 tty multiplexor"); 4637 4638 MODULE_LICENSE("GPL"); 4638 4639 MODULE_ALIAS_LDISC(N_GSM0710);
+1
drivers/tty/n_hdlc.c
··· 822 822 module_init(n_hdlc_init); 823 823 module_exit(n_hdlc_exit); 824 824 825 + MODULE_DESCRIPTION("HDLC line discipline support"); 825 826 MODULE_LICENSE("GPL"); 826 827 MODULE_AUTHOR("Paul Fulghum paulkf@microgate.com"); 827 828 module_param(maxframe, int, 0);
+28 -1
drivers/tty/serial/8250/8250.h
··· 9 9 10 10 #include <linux/bits.h> 11 11 #include <linux/serial_8250.h> 12 - #include <linux/serial_reg.h> 12 + #include <linux/serial_core.h> 13 13 #include <linux/dmaengine.h> 14 14 15 15 #include "../serial_mctrl_gpio.h" ··· 93 93 #define UART_BUG_THRE BIT(3) /* UART has buggy THRE reassertion */ 94 94 #define UART_BUG_TXRACE BIT(5) /* UART Tx fails to set remote DR */ 95 95 96 + /* Module parameters */ 97 + #define UART_NR CONFIG_SERIAL_8250_NR_UARTS 98 + 99 + extern unsigned int nr_uarts; 96 100 97 101 #ifdef CONFIG_SERIAL_8250_SHARE_IRQ 98 102 #define SERIAL8250_SHARE_IRQS 1 99 103 #else 100 104 #define SERIAL8250_SHARE_IRQS 0 101 105 #endif 106 + 107 + extern unsigned int share_irqs; 108 + extern unsigned int skip_txen_test; 102 109 103 110 #define SERIAL8250_PORT_FLAGS(_base, _irq, _flags) \ 104 111 { \ ··· 118 111 119 112 #define SERIAL8250_PORT(_base, _irq) SERIAL8250_PORT_FLAGS(_base, _irq, 0) 120 113 114 + extern struct uart_driver serial8250_reg; 115 + void serial8250_register_ports(struct uart_driver *drv, struct device *dev); 116 + 117 + /* Legacy ISA bus related APIs */ 118 + typedef void (*serial8250_isa_config_fn)(int, struct uart_port *, u32 *); 119 + extern serial8250_isa_config_fn serial8250_isa_config; 120 + 121 + void serial8250_isa_init_ports(void); 122 + 123 + extern struct platform_device *serial8250_isa_devs; 124 + 125 + extern const struct uart_ops *univ8250_port_base_ops; 126 + extern struct uart_ops univ8250_port_ops; 121 127 122 128 static inline int serial_in(struct uart_8250_port *up, int offset) 123 129 { ··· 220 200 return true; 221 201 } 222 202 203 + struct uart_8250_port *serial8250_setup_port(int index); 223 204 struct uart_8250_port *serial8250_get_port(int line); 224 205 225 206 void serial8250_rpm_get(struct uart_8250_port *p); ··· 320 299 #else 321 300 static inline int serial8250_pnp_init(void) { return 0; } 322 301 static inline void serial8250_pnp_exit(void) { } 302 + #endif 303 + 304 + #ifdef CONFIG_SERIAL_8250_RSA 305 + void univ8250_rsa_support(struct uart_ops *ops); 306 + #else 307 + static inline void univ8250_rsa_support(struct uart_ops *ops) { } 323 308 #endif 324 309 325 310 #ifdef CONFIG_SERIAL_8250_FINTEK
+8 -452
drivers/tty/serial/8250/8250_core.c
··· 6 6 * 7 7 * Copyright (C) 2001 Russell King. 8 8 * 9 - * Supports: ISA-compatible 8250/16550 ports 10 - * PNP 8250/16550 ports 9 + * Supports: 11 10 * early_serial_setup() ports 12 11 * userspace-configurable "phantom" ports 13 - * "serial8250" platform devices 14 12 * serial8250_register_8250_port() ports 15 13 */ 16 14 ··· 33 35 #include <linux/string_helpers.h> 34 36 #include <linux/uaccess.h> 35 37 #include <linux/io.h> 36 - #ifdef CONFIG_SPARC 37 - #include <linux/sunserialcore.h> 38 - #endif 39 38 40 39 #include <asm/irq.h> 41 40 42 41 #include "8250.h" 43 42 44 - /* 45 - * Configuration: 46 - * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option 47 - * is unsafe when used on edge-triggered interrupts. 48 - */ 49 - static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; 50 - 51 - static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; 52 - 53 - static struct uart_driver serial8250_reg; 54 - 55 - static unsigned int skip_txen_test; /* force skip of txen test at init time */ 56 - 57 43 #define PASS_LIMIT 512 58 - 59 - #include <asm/serial.h> 60 - /* 61 - * SERIAL_PORT_DFNS tells us about built-in ports that have no 62 - * standard enumeration mechanism. Platforms that can find all 63 - * serial ports via mechanisms like ACPI or PCI need not supply it. 64 - */ 65 - #ifndef SERIAL_PORT_DFNS 66 - #define SERIAL_PORT_DFNS 67 - #endif 68 - 69 - static const struct old_serial_port old_serial_port[] = { 70 - SERIAL_PORT_DFNS /* defined in asm/serial.h */ 71 - }; 72 - 73 - #define UART_NR CONFIG_SERIAL_8250_NR_UARTS 74 - 75 - #ifdef CONFIG_SERIAL_8250_RSA 76 - 77 - #define PORT_RSA_MAX 4 78 - static unsigned long probe_rsa[PORT_RSA_MAX]; 79 - static unsigned int probe_rsa_count; 80 - #endif /* CONFIG_SERIAL_8250_RSA */ 81 44 82 45 struct irq_info { 83 46 struct hlist_node node; ··· 304 345 serial_unlink_irq_chain(up); 305 346 } 306 347 307 - #ifdef CONFIG_SERIAL_8250_RSA 308 - static int serial8250_request_rsa_resource(struct uart_8250_port *up) 309 - { 310 - unsigned long start = UART_RSA_BASE << up->port.regshift; 311 - unsigned int size = 8 << up->port.regshift; 312 - struct uart_port *port = &up->port; 313 - int ret = -EINVAL; 314 - 315 - switch (port->iotype) { 316 - case UPIO_HUB6: 317 - case UPIO_PORT: 318 - start += port->iobase; 319 - if (request_region(start, size, "serial-rsa")) 320 - ret = 0; 321 - else 322 - ret = -EBUSY; 323 - break; 324 - } 325 - 326 - return ret; 327 - } 328 - 329 - static void serial8250_release_rsa_resource(struct uart_8250_port *up) 330 - { 331 - unsigned long offset = UART_RSA_BASE << up->port.regshift; 332 - unsigned int size = 8 << up->port.regshift; 333 - struct uart_port *port = &up->port; 334 - 335 - switch (port->iotype) { 336 - case UPIO_HUB6: 337 - case UPIO_PORT: 338 - release_region(port->iobase + offset, size); 339 - break; 340 - } 341 - } 342 - #endif 343 - 344 - static const struct uart_ops *base_ops; 345 - static struct uart_ops univ8250_port_ops; 348 + const struct uart_ops *univ8250_port_base_ops = NULL; 349 + struct uart_ops univ8250_port_ops; 346 350 347 351 static const struct uart_8250_ops univ8250_driver_ops = { 348 352 .setup_irq = univ8250_setup_irq, ··· 333 411 } 334 412 EXPORT_SYMBOL_GPL(serial8250_get_port); 335 413 336 - static void (*serial8250_isa_config)(int port, struct uart_port *up, 337 - u32 *capabilities); 338 - 339 - void serial8250_set_isa_configurator( 340 - void (*v)(int port, struct uart_port *up, u32 *capabilities)) 341 - { 342 - serial8250_isa_config = v; 343 - } 344 - EXPORT_SYMBOL(serial8250_set_isa_configurator); 345 - 346 - #ifdef CONFIG_SERIAL_8250_RSA 347 - 348 - static void univ8250_config_port(struct uart_port *port, int flags) 349 - { 350 - struct uart_8250_port *up = up_to_u8250p(port); 351 - 352 - up->probe &= ~UART_PROBE_RSA; 353 - if (port->type == PORT_RSA) { 354 - if (serial8250_request_rsa_resource(up) == 0) 355 - up->probe |= UART_PROBE_RSA; 356 - } else if (flags & UART_CONFIG_TYPE) { 357 - int i; 358 - 359 - for (i = 0; i < probe_rsa_count; i++) { 360 - if (probe_rsa[i] == up->port.iobase) { 361 - if (serial8250_request_rsa_resource(up) == 0) 362 - up->probe |= UART_PROBE_RSA; 363 - break; 364 - } 365 - } 366 - } 367 - 368 - base_ops->config_port(port, flags); 369 - 370 - if (port->type != PORT_RSA && up->probe & UART_PROBE_RSA) 371 - serial8250_release_rsa_resource(up); 372 - } 373 - 374 - static int univ8250_request_port(struct uart_port *port) 375 - { 376 - struct uart_8250_port *up = up_to_u8250p(port); 377 - int ret; 378 - 379 - ret = base_ops->request_port(port); 380 - if (ret == 0 && port->type == PORT_RSA) { 381 - ret = serial8250_request_rsa_resource(up); 382 - if (ret < 0) 383 - base_ops->release_port(port); 384 - } 385 - 386 - return ret; 387 - } 388 - 389 - static void univ8250_release_port(struct uart_port *port) 390 - { 391 - struct uart_8250_port *up = up_to_u8250p(port); 392 - 393 - if (port->type == PORT_RSA) 394 - serial8250_release_rsa_resource(up); 395 - base_ops->release_port(port); 396 - } 397 - 398 - static void univ8250_rsa_support(struct uart_ops *ops) 399 - { 400 - ops->config_port = univ8250_config_port; 401 - ops->request_port = univ8250_request_port; 402 - ops->release_port = univ8250_release_port; 403 - } 404 - 405 - #else 406 - #define univ8250_rsa_support(x) do { } while (0) 407 - #endif /* CONFIG_SERIAL_8250_RSA */ 408 - 409 414 static inline void serial8250_apply_quirks(struct uart_8250_port *up) 410 415 { 411 416 up->port.quirks |= skip_txen_test ? UPQ_NO_TXEN_TEST : 0; 412 417 } 413 418 414 - static struct uart_8250_port *serial8250_setup_port(int index) 419 + struct uart_8250_port *serial8250_setup_port(int index) 415 420 { 416 421 struct uart_8250_port *up; 417 422 ··· 350 501 up->port.port_id = index; 351 502 352 503 serial8250_init_port(up); 353 - if (!base_ops) 354 - base_ops = up->port.ops; 504 + if (!univ8250_port_base_ops) 505 + univ8250_port_base_ops = up->port.ops; 355 506 up->port.ops = &univ8250_port_ops; 356 507 357 508 timer_setup(&up->timer, serial8250_timeout, 0); ··· 363 514 return up; 364 515 } 365 516 366 - static void __init serial8250_isa_init_ports(void) 367 - { 368 - struct uart_8250_port *up; 369 - static int first = 1; 370 - int i, irqflag = 0; 371 - 372 - if (!first) 373 - return; 374 - first = 0; 375 - 376 - if (nr_uarts > UART_NR) 377 - nr_uarts = UART_NR; 378 - 379 - /* 380 - * Set up initial isa ports based on nr_uart module param, or else 381 - * default to CONFIG_SERIAL_8250_RUNTIME_UARTS. Note that we do not 382 - * need to increase nr_uarts when setting up the initial isa ports. 383 - */ 384 - for (i = 0; i < nr_uarts; i++) 385 - serial8250_setup_port(i); 386 - 387 - /* chain base port ops to support Remote Supervisor Adapter */ 388 - univ8250_port_ops = *base_ops; 389 - univ8250_rsa_support(&univ8250_port_ops); 390 - 391 - if (share_irqs) 392 - irqflag = IRQF_SHARED; 393 - 394 - for (i = 0, up = serial8250_ports; 395 - i < ARRAY_SIZE(old_serial_port) && i < nr_uarts; 396 - i++, up++) { 397 - struct uart_port *port = &up->port; 398 - 399 - port->iobase = old_serial_port[i].port; 400 - port->irq = irq_canonicalize(old_serial_port[i].irq); 401 - port->irqflags = 0; 402 - port->uartclk = old_serial_port[i].baud_base * 16; 403 - port->flags = old_serial_port[i].flags; 404 - port->hub6 = 0; 405 - port->membase = old_serial_port[i].iomem_base; 406 - port->iotype = old_serial_port[i].io_type; 407 - port->regshift = old_serial_port[i].iomem_reg_shift; 408 - 409 - port->irqflags |= irqflag; 410 - if (serial8250_isa_config != NULL) 411 - serial8250_isa_config(i, &up->port, &up->capabilities); 412 - } 413 - } 414 - 415 - static void __init 416 - serial8250_register_ports(struct uart_driver *drv, struct device *dev) 517 + void __init serial8250_register_ports(struct uart_driver *drv, struct device *dev) 417 518 { 418 519 int i; 419 520 ··· 520 721 #define SERIAL8250_CONSOLE NULL 521 722 #endif 522 723 523 - static struct uart_driver serial8250_reg = { 724 + struct uart_driver serial8250_reg = { 524 725 .owner = THIS_MODULE, 525 726 .driver_name = "serial", 526 727 .dev_name = "ttyS", ··· 620 821 uart_resume_port(&serial8250_reg, port); 621 822 } 622 823 EXPORT_SYMBOL(serial8250_resume_port); 623 - 624 - /* 625 - * Register a set of serial devices attached to a platform device. The 626 - * list is terminated with a zero flags entry, which means we expect 627 - * all entries to have at least UPF_BOOT_AUTOCONF set. 628 - */ 629 - static int serial8250_probe(struct platform_device *dev) 630 - { 631 - struct plat_serial8250_port *p = dev_get_platdata(&dev->dev); 632 - struct uart_8250_port uart; 633 - int ret, i, irqflag = 0; 634 - 635 - memset(&uart, 0, sizeof(uart)); 636 - 637 - if (share_irqs) 638 - irqflag = IRQF_SHARED; 639 - 640 - for (i = 0; p && p->flags != 0; p++, i++) { 641 - uart.port.iobase = p->iobase; 642 - uart.port.membase = p->membase; 643 - uart.port.irq = p->irq; 644 - uart.port.irqflags = p->irqflags; 645 - uart.port.uartclk = p->uartclk; 646 - uart.port.regshift = p->regshift; 647 - uart.port.iotype = p->iotype; 648 - uart.port.flags = p->flags; 649 - uart.port.mapbase = p->mapbase; 650 - uart.port.mapsize = p->mapsize; 651 - uart.port.hub6 = p->hub6; 652 - uart.port.has_sysrq = p->has_sysrq; 653 - uart.port.private_data = p->private_data; 654 - uart.port.type = p->type; 655 - uart.bugs = p->bugs; 656 - uart.port.serial_in = p->serial_in; 657 - uart.port.serial_out = p->serial_out; 658 - uart.dl_read = p->dl_read; 659 - uart.dl_write = p->dl_write; 660 - uart.port.handle_irq = p->handle_irq; 661 - uart.port.handle_break = p->handle_break; 662 - uart.port.set_termios = p->set_termios; 663 - uart.port.set_ldisc = p->set_ldisc; 664 - uart.port.get_mctrl = p->get_mctrl; 665 - uart.port.pm = p->pm; 666 - uart.port.dev = &dev->dev; 667 - uart.port.irqflags |= irqflag; 668 - ret = serial8250_register_8250_port(&uart); 669 - if (ret < 0) { 670 - dev_err(&dev->dev, "unable to register port at index %d " 671 - "(IO%lx MEM%llx IRQ%d): %d\n", i, 672 - p->iobase, (unsigned long long)p->mapbase, 673 - p->irq, ret); 674 - } 675 - } 676 - return 0; 677 - } 678 - 679 - /* 680 - * Remove serial ports registered against a platform device. 681 - */ 682 - static void serial8250_remove(struct platform_device *dev) 683 - { 684 - int i; 685 - 686 - for (i = 0; i < nr_uarts; i++) { 687 - struct uart_8250_port *up = &serial8250_ports[i]; 688 - 689 - if (up->port.dev == &dev->dev) 690 - serial8250_unregister_port(i); 691 - } 692 - } 693 - 694 - static int serial8250_suspend(struct platform_device *dev, pm_message_t state) 695 - { 696 - int i; 697 - 698 - for (i = 0; i < UART_NR; i++) { 699 - struct uart_8250_port *up = &serial8250_ports[i]; 700 - 701 - if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) 702 - uart_suspend_port(&serial8250_reg, &up->port); 703 - } 704 - 705 - return 0; 706 - } 707 - 708 - static int serial8250_resume(struct platform_device *dev) 709 - { 710 - int i; 711 - 712 - for (i = 0; i < UART_NR; i++) { 713 - struct uart_8250_port *up = &serial8250_ports[i]; 714 - 715 - if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) 716 - serial8250_resume_port(i); 717 - } 718 - 719 - return 0; 720 - } 721 - 722 - static struct platform_driver serial8250_isa_driver = { 723 - .probe = serial8250_probe, 724 - .remove_new = serial8250_remove, 725 - .suspend = serial8250_suspend, 726 - .resume = serial8250_resume, 727 - .driver = { 728 - .name = "serial8250", 729 - }, 730 - }; 731 - 732 - /* 733 - * This "device" covers _all_ ISA 8250-compatible serial devices listed 734 - * in the table in include/asm/serial.h 735 - */ 736 - static struct platform_device *serial8250_isa_devs; 737 824 738 825 /* 739 826 * serial8250_register_8250_port and serial8250_unregister_port allows for ··· 897 1212 } 898 1213 EXPORT_SYMBOL(serial8250_unregister_port); 899 1214 900 - static int __init serial8250_init(void) 901 - { 902 - int ret; 903 - 904 - if (nr_uarts == 0) 905 - return -ENODEV; 906 - 907 - serial8250_isa_init_ports(); 908 - 909 - pr_info("Serial: 8250/16550 driver, %d ports, IRQ sharing %s\n", 910 - nr_uarts, str_enabled_disabled(share_irqs)); 911 - 912 - #ifdef CONFIG_SPARC 913 - ret = sunserial_register_minors(&serial8250_reg, UART_NR); 914 - #else 915 - serial8250_reg.nr = UART_NR; 916 - ret = uart_register_driver(&serial8250_reg); 917 - #endif 918 - if (ret) 919 - goto out; 920 - 921 - ret = serial8250_pnp_init(); 922 - if (ret) 923 - goto unreg_uart_drv; 924 - 925 - serial8250_isa_devs = platform_device_alloc("serial8250", 926 - PLAT8250_DEV_LEGACY); 927 - if (!serial8250_isa_devs) { 928 - ret = -ENOMEM; 929 - goto unreg_pnp; 930 - } 931 - 932 - ret = platform_device_add(serial8250_isa_devs); 933 - if (ret) 934 - goto put_dev; 935 - 936 - serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev); 937 - 938 - ret = platform_driver_register(&serial8250_isa_driver); 939 - if (ret == 0) 940 - goto out; 941 - 942 - platform_device_del(serial8250_isa_devs); 943 - put_dev: 944 - platform_device_put(serial8250_isa_devs); 945 - unreg_pnp: 946 - serial8250_pnp_exit(); 947 - unreg_uart_drv: 948 - #ifdef CONFIG_SPARC 949 - sunserial_unregister_minors(&serial8250_reg, UART_NR); 950 - #else 951 - uart_unregister_driver(&serial8250_reg); 952 - #endif 953 - out: 954 - return ret; 955 - } 956 - 957 - static void __exit serial8250_exit(void) 958 - { 959 - struct platform_device *isa_dev = serial8250_isa_devs; 960 - 961 - /* 962 - * This tells serial8250_unregister_port() not to re-register 963 - * the ports (thereby making serial8250_isa_driver permanently 964 - * in use.) 965 - */ 966 - serial8250_isa_devs = NULL; 967 - 968 - platform_driver_unregister(&serial8250_isa_driver); 969 - platform_device_unregister(isa_dev); 970 - 971 - serial8250_pnp_exit(); 972 - 973 - #ifdef CONFIG_SPARC 974 - sunserial_unregister_minors(&serial8250_reg, UART_NR); 975 - #else 976 - uart_unregister_driver(&serial8250_reg); 977 - #endif 978 - } 979 - 980 - module_init(serial8250_init); 981 - module_exit(serial8250_exit); 982 - 983 1215 MODULE_LICENSE("GPL"); 984 1216 MODULE_DESCRIPTION("Generic 8250/16x50 serial driver"); 985 - 986 - module_param_hw(share_irqs, uint, other, 0644); 987 - MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices (unsafe)"); 988 - 989 - module_param(nr_uarts, uint, 0644); 990 - MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")"); 991 - 992 - module_param(skip_txen_test, uint, 0644); 993 - MODULE_PARM_DESC(skip_txen_test, "Skip checking for the TXEN bug at init time"); 994 - 995 - #ifdef CONFIG_SERIAL_8250_RSA 996 - module_param_hw_array(probe_rsa, ulong, ioport, &probe_rsa_count, 0444); 997 - MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); 998 - #endif 999 - MODULE_ALIAS_CHARDEV_MAJOR(TTY_MAJOR); 1000 - 1001 - #ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS 1002 - #ifndef MODULE 1003 - /* This module was renamed to 8250_core in 3.7. Keep the old "8250" name 1004 - * working as well for the module options so we don't break people. We 1005 - * need to keep the names identical and the convenient macros will happily 1006 - * refuse to let us do that by failing the build with redefinition errors 1007 - * of global variables. So we stick them inside a dummy function to avoid 1008 - * those conflicts. The options still get parsed, and the redefined 1009 - * MODULE_PARAM_PREFIX lets us keep the "8250." syntax alive. 1010 - * 1011 - * This is hacky. I'm sorry. 1012 - */ 1013 - static void __used s8250_options(void) 1014 - { 1015 - #undef MODULE_PARAM_PREFIX 1016 - #define MODULE_PARAM_PREFIX "8250_core." 1017 - 1018 - module_param_cb(share_irqs, &param_ops_uint, &share_irqs, 0644); 1019 - module_param_cb(nr_uarts, &param_ops_uint, &nr_uarts, 0644); 1020 - module_param_cb(skip_txen_test, &param_ops_uint, &skip_txen_test, 0644); 1021 - #ifdef CONFIG_SERIAL_8250_RSA 1022 - __module_param_call(MODULE_PARAM_PREFIX, probe_rsa, 1023 - &param_array_ops, .arr = &__param_arr_probe_rsa, 1024 - 0444, -1, 0); 1025 - #endif 1026 - } 1027 - #else 1028 - MODULE_ALIAS("8250_core"); 1029 - #endif 1030 - #endif
+1 -1
drivers/tty/serial/8250/8250_dw.c
··· 616 616 if (IS_ERR(data->pclk)) 617 617 return PTR_ERR(data->pclk); 618 618 619 - data->rst = devm_reset_control_get_optional_exclusive(dev, NULL); 619 + data->rst = devm_reset_control_array_get_optional_exclusive(dev); 620 620 if (IS_ERR(data->rst)) 621 621 return PTR_ERR(data->rst); 622 622
+1
drivers/tty/serial/8250/8250_parisc.c
··· 127 127 128 128 module_init(probe_serial_gsc); 129 129 130 + MODULE_DESCRIPTION("Serial Device Initialisation for Lasi/Asp/Wax/Dino"); 130 131 MODULE_LICENSE("GPL");
+1
drivers/tty/serial/8250/8250_pcilib.c
··· 37 37 return 0; 38 38 } 39 39 EXPORT_SYMBOL_NS_GPL(serial8250_pci_setup_port, SERIAL_8250_PCI); 40 + MODULE_DESCRIPTION("8250 PCI library"); 40 41 MODULE_LICENSE("GPL");
+337
drivers/tty/serial/8250/8250_platform.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Universal/legacy platform driver for 8250/16550-type serial ports 4 + * 5 + * Supports: ISA-compatible 8250/16550 ports 6 + * PNP 8250/16550 ports 7 + * "serial8250" platform devices 8 + */ 9 + #include <linux/array_size.h> 10 + #include <linux/module.h> 11 + #include <linux/moduleparam.h> 12 + #include <linux/once.h> 13 + #include <linux/platform_device.h> 14 + 15 + #include <linux/serial_8250.h> 16 + 17 + #ifdef CONFIG_SPARC 18 + #include <linux/sunserialcore.h> 19 + #endif 20 + 21 + #include "8250.h" 22 + 23 + /* 24 + * Configuration: 25 + * share_irqs Whether we pass IRQF_SHARED to request_irq(). 26 + * This option is unsafe when used on edge-triggered interrupts. 27 + * skip_txen_test Force skip of txen test at init time. 28 + */ 29 + unsigned int share_irqs = SERIAL8250_SHARE_IRQS; 30 + unsigned int skip_txen_test; 31 + 32 + unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; 33 + 34 + #include <asm/serial.h> 35 + 36 + /* 37 + * SERIAL_PORT_DFNS tells us about built-in ports that have no 38 + * standard enumeration mechanism. Platforms that can find all 39 + * serial ports via mechanisms like ACPI or PCI need not supply it. 40 + */ 41 + #ifndef SERIAL_PORT_DFNS 42 + #define SERIAL_PORT_DFNS 43 + #endif 44 + 45 + static const struct old_serial_port old_serial_port[] = { 46 + SERIAL_PORT_DFNS /* defined in asm/serial.h */ 47 + }; 48 + 49 + serial8250_isa_config_fn serial8250_isa_config; 50 + void serial8250_set_isa_configurator(serial8250_isa_config_fn v) 51 + { 52 + serial8250_isa_config = v; 53 + } 54 + EXPORT_SYMBOL(serial8250_set_isa_configurator); 55 + 56 + static void __init __serial8250_isa_init_ports(void) 57 + { 58 + int i, irqflag = 0; 59 + 60 + if (nr_uarts > UART_NR) 61 + nr_uarts = UART_NR; 62 + 63 + /* 64 + * Set up initial isa ports based on nr_uart module param, or else 65 + * default to CONFIG_SERIAL_8250_RUNTIME_UARTS. Note that we do not 66 + * need to increase nr_uarts when setting up the initial isa ports. 67 + */ 68 + for (i = 0; i < nr_uarts; i++) 69 + serial8250_setup_port(i); 70 + 71 + /* chain base port ops to support Remote Supervisor Adapter */ 72 + univ8250_port_ops = *univ8250_port_base_ops; 73 + univ8250_rsa_support(&univ8250_port_ops); 74 + 75 + if (share_irqs) 76 + irqflag = IRQF_SHARED; 77 + 78 + for (i = 0; i < ARRAY_SIZE(old_serial_port) && i < nr_uarts; i++) { 79 + struct uart_8250_port *up = serial8250_get_port(i); 80 + struct uart_port *port = &up->port; 81 + 82 + port->iobase = old_serial_port[i].port; 83 + port->irq = irq_canonicalize(old_serial_port[i].irq); 84 + port->irqflags = 0; 85 + port->uartclk = old_serial_port[i].baud_base * 16; 86 + port->flags = old_serial_port[i].flags; 87 + port->hub6 = 0; 88 + port->membase = old_serial_port[i].iomem_base; 89 + port->iotype = old_serial_port[i].io_type; 90 + port->regshift = old_serial_port[i].iomem_reg_shift; 91 + 92 + port->irqflags |= irqflag; 93 + if (serial8250_isa_config != NULL) 94 + serial8250_isa_config(i, &up->port, &up->capabilities); 95 + } 96 + } 97 + 98 + void __init serial8250_isa_init_ports(void) 99 + { 100 + DO_ONCE(__serial8250_isa_init_ports); 101 + } 102 + 103 + /* 104 + * Register a set of serial devices attached to a platform device. The 105 + * list is terminated with a zero flags entry, which means we expect 106 + * all entries to have at least UPF_BOOT_AUTOCONF set. 107 + */ 108 + static int serial8250_probe(struct platform_device *dev) 109 + { 110 + struct plat_serial8250_port *p = dev_get_platdata(&dev->dev); 111 + struct uart_8250_port uart; 112 + int ret, i, irqflag = 0; 113 + 114 + memset(&uart, 0, sizeof(uart)); 115 + 116 + if (share_irqs) 117 + irqflag = IRQF_SHARED; 118 + 119 + for (i = 0; p && p->flags != 0; p++, i++) { 120 + uart.port.iobase = p->iobase; 121 + uart.port.membase = p->membase; 122 + uart.port.irq = p->irq; 123 + uart.port.irqflags = p->irqflags; 124 + uart.port.uartclk = p->uartclk; 125 + uart.port.regshift = p->regshift; 126 + uart.port.iotype = p->iotype; 127 + uart.port.flags = p->flags; 128 + uart.port.mapbase = p->mapbase; 129 + uart.port.mapsize = p->mapsize; 130 + uart.port.hub6 = p->hub6; 131 + uart.port.has_sysrq = p->has_sysrq; 132 + uart.port.private_data = p->private_data; 133 + uart.port.type = p->type; 134 + uart.bugs = p->bugs; 135 + uart.port.serial_in = p->serial_in; 136 + uart.port.serial_out = p->serial_out; 137 + uart.dl_read = p->dl_read; 138 + uart.dl_write = p->dl_write; 139 + uart.port.handle_irq = p->handle_irq; 140 + uart.port.handle_break = p->handle_break; 141 + uart.port.set_termios = p->set_termios; 142 + uart.port.set_ldisc = p->set_ldisc; 143 + uart.port.get_mctrl = p->get_mctrl; 144 + uart.port.pm = p->pm; 145 + uart.port.dev = &dev->dev; 146 + uart.port.irqflags |= irqflag; 147 + ret = serial8250_register_8250_port(&uart); 148 + if (ret < 0) { 149 + dev_err(&dev->dev, "unable to register port at index %d " 150 + "(IO%lx MEM%llx IRQ%d): %d\n", i, 151 + p->iobase, (unsigned long long)p->mapbase, 152 + p->irq, ret); 153 + } 154 + } 155 + return 0; 156 + } 157 + 158 + /* 159 + * Remove serial ports registered against a platform device. 160 + */ 161 + static void serial8250_remove(struct platform_device *dev) 162 + { 163 + int i; 164 + 165 + for (i = 0; i < nr_uarts; i++) { 166 + struct uart_8250_port *up = serial8250_get_port(i); 167 + 168 + if (up->port.dev == &dev->dev) 169 + serial8250_unregister_port(i); 170 + } 171 + } 172 + 173 + static int serial8250_suspend(struct platform_device *dev, pm_message_t state) 174 + { 175 + int i; 176 + 177 + for (i = 0; i < UART_NR; i++) { 178 + struct uart_8250_port *up = serial8250_get_port(i); 179 + 180 + if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) 181 + uart_suspend_port(&serial8250_reg, &up->port); 182 + } 183 + 184 + return 0; 185 + } 186 + 187 + static int serial8250_resume(struct platform_device *dev) 188 + { 189 + int i; 190 + 191 + for (i = 0; i < UART_NR; i++) { 192 + struct uart_8250_port *up = serial8250_get_port(i); 193 + 194 + if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev) 195 + serial8250_resume_port(i); 196 + } 197 + 198 + return 0; 199 + } 200 + 201 + static struct platform_driver serial8250_isa_driver = { 202 + .probe = serial8250_probe, 203 + .remove_new = serial8250_remove, 204 + .suspend = serial8250_suspend, 205 + .resume = serial8250_resume, 206 + .driver = { 207 + .name = "serial8250", 208 + }, 209 + }; 210 + 211 + /* 212 + * This "device" covers _all_ ISA 8250-compatible serial devices listed 213 + * in the table in include/asm/serial.h 214 + */ 215 + struct platform_device *serial8250_isa_devs; 216 + 217 + static int __init serial8250_init(void) 218 + { 219 + int ret; 220 + 221 + if (nr_uarts == 0) 222 + return -ENODEV; 223 + 224 + serial8250_isa_init_ports(); 225 + 226 + pr_info("Serial: 8250/16550 driver, %d ports, IRQ sharing %s\n", 227 + nr_uarts, str_enabled_disabled(share_irqs)); 228 + 229 + #ifdef CONFIG_SPARC 230 + ret = sunserial_register_minors(&serial8250_reg, UART_NR); 231 + #else 232 + serial8250_reg.nr = UART_NR; 233 + ret = uart_register_driver(&serial8250_reg); 234 + #endif 235 + if (ret) 236 + goto out; 237 + 238 + ret = serial8250_pnp_init(); 239 + if (ret) 240 + goto unreg_uart_drv; 241 + 242 + serial8250_isa_devs = platform_device_alloc("serial8250", 243 + PLAT8250_DEV_LEGACY); 244 + if (!serial8250_isa_devs) { 245 + ret = -ENOMEM; 246 + goto unreg_pnp; 247 + } 248 + 249 + ret = platform_device_add(serial8250_isa_devs); 250 + if (ret) 251 + goto put_dev; 252 + 253 + serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev); 254 + 255 + ret = platform_driver_register(&serial8250_isa_driver); 256 + if (ret == 0) 257 + goto out; 258 + 259 + platform_device_del(serial8250_isa_devs); 260 + put_dev: 261 + platform_device_put(serial8250_isa_devs); 262 + unreg_pnp: 263 + serial8250_pnp_exit(); 264 + unreg_uart_drv: 265 + #ifdef CONFIG_SPARC 266 + sunserial_unregister_minors(&serial8250_reg, UART_NR); 267 + #else 268 + uart_unregister_driver(&serial8250_reg); 269 + #endif 270 + out: 271 + return ret; 272 + } 273 + module_init(serial8250_init); 274 + 275 + static void __exit serial8250_exit(void) 276 + { 277 + struct platform_device *isa_dev = serial8250_isa_devs; 278 + 279 + /* 280 + * This tells serial8250_unregister_port() not to re-register 281 + * the ports (thereby making serial8250_isa_driver permanently 282 + * in use.) 283 + */ 284 + serial8250_isa_devs = NULL; 285 + 286 + platform_driver_unregister(&serial8250_isa_driver); 287 + platform_device_unregister(isa_dev); 288 + 289 + serial8250_pnp_exit(); 290 + 291 + #ifdef CONFIG_SPARC 292 + sunserial_unregister_minors(&serial8250_reg, UART_NR); 293 + #else 294 + uart_unregister_driver(&serial8250_reg); 295 + #endif 296 + } 297 + module_exit(serial8250_exit); 298 + 299 + MODULE_LICENSE("GPL"); 300 + MODULE_DESCRIPTION("Generic 8250/16x50 serial platform driver"); 301 + 302 + module_param_hw(share_irqs, uint, other, 0644); 303 + MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices (unsafe)"); 304 + 305 + module_param(nr_uarts, uint, 0644); 306 + MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")"); 307 + 308 + module_param(skip_txen_test, uint, 0644); 309 + MODULE_PARM_DESC(skip_txen_test, "Skip checking for the TXEN bug at init time"); 310 + 311 + MODULE_ALIAS_CHARDEV_MAJOR(TTY_MAJOR); 312 + 313 + #ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS 314 + #ifndef MODULE 315 + /* This module was renamed to 8250_core in 3.7. Keep the old "8250" name 316 + * working as well for the module options so we don't break people. We 317 + * need to keep the names identical and the convenient macros will happily 318 + * refuse to let us do that by failing the build with redefinition errors 319 + * of global variables. So we stick them inside a dummy function to avoid 320 + * those conflicts. The options still get parsed, and the redefined 321 + * MODULE_PARAM_PREFIX lets us keep the "8250." syntax alive. 322 + * 323 + * This is hacky. I'm sorry. 324 + */ 325 + static void __used s8250_options(void) 326 + { 327 + #undef MODULE_PARAM_PREFIX 328 + #define MODULE_PARAM_PREFIX "8250_core." 329 + 330 + module_param_cb(share_irqs, &param_ops_uint, &share_irqs, 0644); 331 + module_param_cb(nr_uarts, &param_ops_uint, &nr_uarts, 0644); 332 + module_param_cb(skip_txen_test, &param_ops_uint, &skip_txen_test, 0644); 333 + } 334 + #else 335 + MODULE_ALIAS("8250_core"); 336 + #endif 337 + #endif
+1
drivers/tty/serial/8250/8250_port.c
··· 3473 3473 3474 3474 #endif /* CONFIG_SERIAL_8250_CONSOLE */ 3475 3475 3476 + MODULE_DESCRIPTION("Base port operations for 8250/16550-type serial ports"); 3476 3477 MODULE_LICENSE("GPL");
+1
drivers/tty/serial/8250/8250_pxa.c
··· 182 182 #endif 183 183 184 184 MODULE_AUTHOR("Sergei Ianovich"); 185 + MODULE_DESCRIPTION("driver for PXA on-board UARTS"); 185 186 MODULE_LICENSE("GPL"); 186 187 MODULE_ALIAS("platform:pxa2xx-uart");
+133
drivers/tty/serial/8250/8250_rsa.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + 3 + #include <linux/errno.h> 4 + #include <linux/ioport.h> 5 + #include <linux/module.h> 6 + #include <linux/moduleparam.h> 7 + 8 + #include <linux/serial.h> 9 + #include <linux/serial_8250.h> 10 + 11 + #include "8250.h" 12 + 13 + #define PORT_RSA_MAX 4 14 + static unsigned long probe_rsa[PORT_RSA_MAX]; 15 + static unsigned int probe_rsa_count; 16 + 17 + static int rsa8250_request_resource(struct uart_8250_port *up) 18 + { 19 + unsigned long start = UART_RSA_BASE << up->port.regshift; 20 + unsigned int size = 8 << up->port.regshift; 21 + struct uart_port *port = &up->port; 22 + int ret = -EINVAL; 23 + 24 + switch (port->iotype) { 25 + case UPIO_HUB6: 26 + case UPIO_PORT: 27 + start += port->iobase; 28 + if (request_region(start, size, "serial-rsa")) 29 + ret = 0; 30 + else 31 + ret = -EBUSY; 32 + break; 33 + } 34 + 35 + return ret; 36 + } 37 + 38 + static void rsa8250_release_resource(struct uart_8250_port *up) 39 + { 40 + unsigned long offset = UART_RSA_BASE << up->port.regshift; 41 + unsigned int size = 8 << up->port.regshift; 42 + struct uart_port *port = &up->port; 43 + 44 + switch (port->iotype) { 45 + case UPIO_HUB6: 46 + case UPIO_PORT: 47 + release_region(port->iobase + offset, size); 48 + break; 49 + } 50 + } 51 + 52 + static void univ8250_config_port(struct uart_port *port, int flags) 53 + { 54 + struct uart_8250_port *up = up_to_u8250p(port); 55 + unsigned int i; 56 + 57 + up->probe &= ~UART_PROBE_RSA; 58 + if (port->type == PORT_RSA) { 59 + if (rsa8250_request_resource(up) == 0) 60 + up->probe |= UART_PROBE_RSA; 61 + } else if (flags & UART_CONFIG_TYPE) { 62 + for (i = 0; i < probe_rsa_count; i++) { 63 + if (probe_rsa[i] == up->port.iobase) { 64 + if (rsa8250_request_resource(up) == 0) 65 + up->probe |= UART_PROBE_RSA; 66 + break; 67 + } 68 + } 69 + } 70 + 71 + univ8250_port_base_ops->config_port(port, flags); 72 + 73 + if (port->type != PORT_RSA && up->probe & UART_PROBE_RSA) 74 + rsa8250_release_resource(up); 75 + } 76 + 77 + static int univ8250_request_port(struct uart_port *port) 78 + { 79 + struct uart_8250_port *up = up_to_u8250p(port); 80 + int ret; 81 + 82 + ret = univ8250_port_base_ops->request_port(port); 83 + if (ret == 0 && port->type == PORT_RSA) { 84 + ret = rsa8250_request_resource(up); 85 + if (ret < 0) 86 + univ8250_port_base_ops->release_port(port); 87 + } 88 + 89 + return ret; 90 + } 91 + 92 + static void univ8250_release_port(struct uart_port *port) 93 + { 94 + struct uart_8250_port *up = up_to_u8250p(port); 95 + 96 + if (port->type == PORT_RSA) 97 + rsa8250_release_resource(up); 98 + univ8250_port_base_ops->release_port(port); 99 + } 100 + 101 + void univ8250_rsa_support(struct uart_ops *ops) 102 + { 103 + ops->config_port = univ8250_config_port; 104 + ops->request_port = univ8250_request_port; 105 + ops->release_port = univ8250_release_port; 106 + } 107 + 108 + module_param_hw_array(probe_rsa, ulong, ioport, &probe_rsa_count, 0444); 109 + MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA"); 110 + 111 + #ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS 112 + #ifndef MODULE 113 + /* 114 + * Keep the old "8250" name working as well for the module options so we don't 115 + * break people. We need to keep the names identical and the convenient macros 116 + * will happily refuse to let us do that by failing the build with redefinition 117 + * errors of global variables. So we stick them inside a dummy function to 118 + * avoid those conflicts. The options still get parsed, and the redefined 119 + * MODULE_PARAM_PREFIX lets us keep the "8250." syntax alive. 120 + * 121 + * This is hacky. I'm sorry. 122 + */ 123 + static void __used rsa8250_options(void) 124 + { 125 + #undef MODULE_PARAM_PREFIX 126 + #define MODULE_PARAM_PREFIX "8250_core." 127 + 128 + __module_param_call(MODULE_PARAM_PREFIX, probe_rsa, 129 + &param_array_ops, .arr = &__param_arr_probe_rsa, 130 + 0444, -1, 0); 131 + } 132 + #endif 133 + #endif
+5 -1
drivers/tty/serial/8250/Makefile
··· 3 3 # Makefile for the 8250 serial device drivers. 4 4 # 5 5 6 - obj-$(CONFIG_SERIAL_8250) += 8250.o 8250_base.o 6 + obj-$(CONFIG_SERIAL_8250) += 8250.o 7 7 8250-y := 8250_core.o 8 + 8250-y += 8250_platform.o 8 9 8250-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o 10 + 8250-$(CONFIG_SERIAL_8250_RSA) += 8250_rsa.o 11 + 12 + obj-$(CONFIG_SERIAL_8250) += 8250_base.o 9 13 8250_base-y := 8250_port.o 10 14 8250_base-$(CONFIG_SERIAL_8250_DMA) += 8250_dma.o 11 15 8250_base-$(CONFIG_SERIAL_8250_DWLIB) += 8250_dwlib.o
+1
drivers/tty/serial/8250/serial_cs.c
··· 864 864 }; 865 865 module_pcmcia_driver(serial_cs_driver); 866 866 867 + MODULE_DESCRIPTION("driver for PCMCIA serial devices"); 867 868 MODULE_LICENSE("GPL");
+1
drivers/tty/serial/esp32_acm.c
··· 455 455 module_exit(esp32s3_acm_exit); 456 456 457 457 MODULE_AUTHOR("Max Filippov <jcmvbkbc@gmail.com>"); 458 + MODULE_DESCRIPTION("Espressif ESP32 USB ACM gadget support"); 458 459 MODULE_LICENSE("GPL");
+1
drivers/tty/serial/esp32_uart.c
··· 775 775 module_exit(esp32_uart_exit); 776 776 777 777 MODULE_AUTHOR("Max Filippov <jcmvbkbc@gmail.com>"); 778 + MODULE_DESCRIPTION("Espressif ESP32 UART support"); 778 779 MODULE_LICENSE("GPL");
+23 -18
drivers/tty/serial/imx.c
··· 265 265 }; 266 266 MODULE_DEVICE_TABLE(of, imx_uart_dt_ids); 267 267 268 + static inline struct imx_port *to_imx_port(struct uart_port *port) 269 + { 270 + return container_of(port, struct imx_port, port); 271 + } 272 + 268 273 static inline void imx_uart_writel(struct imx_port *sport, u32 val, u32 offset) 269 274 { 270 275 writel(val, sport->port.membase + offset); ··· 383 378 /* called with port.lock taken and irqs off */ 384 379 static void imx_uart_start_rx(struct uart_port *port) 385 380 { 386 - struct imx_port *sport = (struct imx_port *)port; 381 + struct imx_port *sport = to_imx_port(port); 387 382 unsigned int ucr1, ucr2; 388 383 389 384 ucr1 = imx_uart_readl(sport, UCR1); ··· 407 402 /* called with port.lock taken and irqs off */ 408 403 static void imx_uart_stop_tx(struct uart_port *port) 409 404 { 410 - struct imx_port *sport = (struct imx_port *)port; 405 + struct imx_port *sport = to_imx_port(port); 411 406 u32 ucr1, ucr4, usr2; 412 407 413 408 if (sport->tx_state == OFF) ··· 472 467 473 468 static void imx_uart_stop_rx_with_loopback_ctrl(struct uart_port *port, bool loopback) 474 469 { 475 - struct imx_port *sport = (struct imx_port *)port; 470 + struct imx_port *sport = to_imx_port(port); 476 471 u32 ucr1, ucr2, ucr4, uts; 477 472 478 473 ucr1 = imx_uart_readl(sport, UCR1); ··· 517 512 /* called with port.lock taken and irqs off */ 518 513 static void imx_uart_enable_ms(struct uart_port *port) 519 514 { 520 - struct imx_port *sport = (struct imx_port *)port; 515 + struct imx_port *sport = to_imx_port(port); 521 516 522 517 mod_timer(&sport->timer, jiffies); 523 518 ··· 668 663 /* called with port.lock taken and irqs off */ 669 664 static void imx_uart_start_tx(struct uart_port *port) 670 665 { 671 - struct imx_port *sport = (struct imx_port *)port; 666 + struct imx_port *sport = to_imx_port(port); 672 667 struct tty_port *tport = &sport->port.state->port; 673 668 u32 ucr1; 674 669 ··· 1049 1044 */ 1050 1045 static unsigned int imx_uart_tx_empty(struct uart_port *port) 1051 1046 { 1052 - struct imx_port *sport = (struct imx_port *)port; 1047 + struct imx_port *sport = to_imx_port(port); 1053 1048 unsigned int ret; 1054 1049 1055 1050 ret = (imx_uart_readl(sport, USR2) & USR2_TXDC) ? TIOCSER_TEMT : 0; ··· 1064 1059 /* called with port.lock taken and irqs off */ 1065 1060 static unsigned int imx_uart_get_mctrl(struct uart_port *port) 1066 1061 { 1067 - struct imx_port *sport = (struct imx_port *)port; 1062 + struct imx_port *sport = to_imx_port(port); 1068 1063 unsigned int ret = imx_uart_get_hwmctrl(sport); 1069 1064 1070 1065 mctrl_gpio_get(sport->gpios, &ret); ··· 1075 1070 /* called with port.lock taken and irqs off */ 1076 1071 static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 1077 1072 { 1078 - struct imx_port *sport = (struct imx_port *)port; 1073 + struct imx_port *sport = to_imx_port(port); 1079 1074 u32 ucr3, uts; 1080 1075 1081 1076 if (!(port->rs485.flags & SER_RS485_ENABLED)) { ··· 1118 1113 */ 1119 1114 static void imx_uart_break_ctl(struct uart_port *port, int break_state) 1120 1115 { 1121 - struct imx_port *sport = (struct imx_port *)port; 1116 + struct imx_port *sport = to_imx_port(port); 1122 1117 unsigned long flags; 1123 1118 u32 ucr1; 1124 1119 ··· 1440 1435 1441 1436 static int imx_uart_startup(struct uart_port *port) 1442 1437 { 1443 - struct imx_port *sport = (struct imx_port *)port; 1438 + struct imx_port *sport = to_imx_port(port); 1444 1439 int retval; 1445 1440 unsigned long flags; 1446 1441 int dma_is_inited = 0; ··· 1554 1549 1555 1550 static void imx_uart_shutdown(struct uart_port *port) 1556 1551 { 1557 - struct imx_port *sport = (struct imx_port *)port; 1552 + struct imx_port *sport = to_imx_port(port); 1558 1553 unsigned long flags; 1559 1554 u32 ucr1, ucr2, ucr4, uts; 1560 1555 int loops; ··· 1679 1674 /* called with port.lock taken and irqs off */ 1680 1675 static void imx_uart_flush_buffer(struct uart_port *port) 1681 1676 { 1682 - struct imx_port *sport = (struct imx_port *)port; 1677 + struct imx_port *sport = to_imx_port(port); 1683 1678 struct scatterlist *sgl = &sport->tx_sgl[0]; 1684 1679 1685 1680 if (!sport->dma_chan_tx) ··· 1706 1701 imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, 1707 1702 const struct ktermios *old) 1708 1703 { 1709 - struct imx_port *sport = (struct imx_port *)port; 1704 + struct imx_port *sport = to_imx_port(port); 1710 1705 unsigned long flags; 1711 1706 u32 ucr2, old_ucr2, ufcr; 1712 1707 unsigned int baud, quot; ··· 1909 1904 1910 1905 static int imx_uart_poll_init(struct uart_port *port) 1911 1906 { 1912 - struct imx_port *sport = (struct imx_port *)port; 1907 + struct imx_port *sport = to_imx_port(port); 1913 1908 unsigned long flags; 1914 1909 u32 ucr1, ucr2; 1915 1910 int retval; ··· 1958 1953 1959 1954 static int imx_uart_poll_get_char(struct uart_port *port) 1960 1955 { 1961 - struct imx_port *sport = (struct imx_port *)port; 1956 + struct imx_port *sport = to_imx_port(port); 1962 1957 if (!(imx_uart_readl(sport, USR2) & USR2_RDR)) 1963 1958 return NO_POLL_CHAR; 1964 1959 ··· 1967 1962 1968 1963 static void imx_uart_poll_put_char(struct uart_port *port, unsigned char c) 1969 1964 { 1970 - struct imx_port *sport = (struct imx_port *)port; 1965 + struct imx_port *sport = to_imx_port(port); 1971 1966 unsigned int status; 1972 1967 1973 1968 /* drain */ ··· 1989 1984 static int imx_uart_rs485_config(struct uart_port *port, struct ktermios *termios, 1990 1985 struct serial_rs485 *rs485conf) 1991 1986 { 1992 - struct imx_port *sport = (struct imx_port *)port; 1987 + struct imx_port *sport = to_imx_port(port); 1993 1988 u32 ucr2, ufcr; 1994 1989 1995 1990 if (rs485conf->flags & SER_RS485_ENABLED) { ··· 2048 2043 #if IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE) 2049 2044 static void imx_uart_console_putchar(struct uart_port *port, unsigned char ch) 2050 2045 { 2051 - struct imx_port *sport = (struct imx_port *)port; 2046 + struct imx_port *sport = to_imx_port(port); 2052 2047 2053 2048 while (imx_uart_readl(sport, imx_uart_uts_reg(sport)) & UTS_TXFULL) 2054 2049 barrier();
+1
drivers/tty/serial/owl-uart.c
··· 761 761 module_init(owl_uart_init); 762 762 module_exit(owl_uart_exit); 763 763 764 + MODULE_DESCRIPTION("Actions Semi Owl family serial console"); 764 765 MODULE_LICENSE("GPL");
+28 -3
drivers/tty/serial/sc16is7xx.c
··· 14 14 #include <linux/delay.h> 15 15 #include <linux/device.h> 16 16 #include <linux/export.h> 17 + #include <linux/gpio/consumer.h> 17 18 #include <linux/gpio/driver.h> 18 19 #include <linux/idr.h> 19 20 #include <linux/kthread.h> ··· 1468 1467 .delay_rts_after_send = 1, /* Not supported but keep returning -EINVAL */ 1469 1468 }; 1470 1469 1470 + /* Reset device, purging any pending irq / data */ 1471 + static int sc16is7xx_reset(struct device *dev, struct regmap *regmap) 1472 + { 1473 + struct gpio_desc *reset_gpio; 1474 + 1475 + /* Assert reset GPIO if defined and valid. */ 1476 + reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); 1477 + if (IS_ERR(reset_gpio)) 1478 + return dev_err_probe(dev, PTR_ERR(reset_gpio), "Failed to get reset GPIO\n"); 1479 + 1480 + if (reset_gpio) { 1481 + /* The minimum reset pulse width is 3 us. */ 1482 + fsleep(5); 1483 + gpiod_set_value_cansleep(reset_gpio, 0); /* Deassert GPIO */ 1484 + } else { 1485 + /* Software reset */ 1486 + regmap_write(regmap, SC16IS7XX_IOCONTROL_REG, 1487 + SC16IS7XX_IOCONTROL_SRESET_BIT); 1488 + } 1489 + 1490 + return 0; 1491 + } 1492 + 1471 1493 int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, 1472 1494 struct regmap *regmaps[], int irq) 1473 1495 { ··· 1560 1536 } 1561 1537 sched_set_fifo(s->kworker_task); 1562 1538 1563 - /* reset device, purging any pending irq / data */ 1564 - regmap_write(regmaps[0], SC16IS7XX_IOCONTROL_REG, 1565 - SC16IS7XX_IOCONTROL_SRESET_BIT); 1539 + ret = sc16is7xx_reset(dev, regmaps[0]); 1540 + if (ret) 1541 + goto out_kthread; 1566 1542 1567 1543 /* Mark each port line and status as uninitialised. */ 1568 1544 for (i = 0; i < devtype->nr_uart; ++i) { ··· 1687 1663 uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); 1688 1664 } 1689 1665 1666 + out_kthread: 1690 1667 kthread_stop(s->kworker_task); 1691 1668 1692 1669 out_clk:
+16
drivers/tty/serial/serial_base.h
··· 49 49 50 50 int serial_core_register_port(struct uart_driver *drv, struct uart_port *port); 51 51 void serial_core_unregister_port(struct uart_driver *drv, struct uart_port *port); 52 + 53 + #ifdef CONFIG_SERIAL_CORE_CONSOLE 54 + 55 + int serial_base_match_and_update_preferred_console(struct uart_driver *drv, 56 + struct uart_port *port); 57 + 58 + #else 59 + 60 + static inline 61 + int serial_base_match_and_update_preferred_console(struct uart_driver *drv, 62 + struct uart_port *port) 63 + { 64 + return 0; 65 + } 66 + 67 + #endif
+37
drivers/tty/serial/serial_base_bus.c
··· 8 8 * The serial core bus manages the serial core controller instances. 9 9 */ 10 10 11 + #include <linux/cleanup.h> 11 12 #include <linux/container_of.h> 12 13 #include <linux/device.h> 13 14 #include <linux/idr.h> ··· 204 203 ida_free(&ctrl_dev->port_ida, port_dev->port->port_id); 205 204 put_device(&port_dev->dev); 206 205 } 206 + 207 + #ifdef CONFIG_SERIAL_CORE_CONSOLE 208 + 209 + /** 210 + * serial_base_match_and_update_preferred_console - Match and update a preferred console 211 + * @drv: Serial port device driver 212 + * @port: Serial port instance 213 + * 214 + * Tries to match and update the preferred console for a serial port for 215 + * the kernel command line option console=DEVNAME:0.0. 216 + * 217 + * Cannot be called early for ISA ports, depends on struct device. 218 + * 219 + * Return: 0 on success, negative error code on failure. 220 + */ 221 + int serial_base_match_and_update_preferred_console(struct uart_driver *drv, 222 + struct uart_port *port) 223 + { 224 + const char *port_match __free(kfree) = NULL; 225 + int ret; 226 + 227 + port_match = kasprintf(GFP_KERNEL, "%s:%d.%d", dev_name(port->dev), 228 + port->ctrl_id, port->port_id); 229 + if (!port_match) 230 + return -ENOMEM; 231 + 232 + ret = match_devname_and_update_preferred_console(port_match, 233 + drv->dev_name, 234 + port->line); 235 + if (ret == -ENOENT) 236 + return 0; 237 + 238 + return ret; 239 + } 240 + 241 + #endif 207 242 208 243 static int serial_base_init(void) 209 244 {
+4
drivers/tty/serial/serial_core.c
··· 3422 3422 if (ret) 3423 3423 goto err_unregister_ctrl_dev; 3424 3424 3425 + ret = serial_base_match_and_update_preferred_console(drv, port); 3426 + if (ret) 3427 + goto err_unregister_port_dev; 3428 + 3425 3429 ret = serial_core_add_one_port(drv, port); 3426 3430 if (ret) 3427 3431 goto err_unregister_port_dev;
+1
drivers/tty/serial/serial_mctrl_gpio.c
··· 385 385 } 386 386 EXPORT_SYMBOL_GPL(mctrl_gpio_disable_irq_wake); 387 387 388 + MODULE_DESCRIPTION("Helpers for controlling modem lines via GPIO"); 388 389 MODULE_LICENSE("GPL");
+50 -5
drivers/tty/serial/sh-sci.c
··· 318 318 }, 319 319 320 320 /* 321 + * The "SCIF" that is in RZ/V2H(P) SoC is similar to one found on RZ/G2L SoC 322 + * with below differences, 323 + * - Break out of interrupts are different: ERI, BRI, RXI, TXI, TEI, DRI, 324 + * TEI-DRI, RXI-EDGE and TXI-EDGE. 325 + * - SCSMR register does not have CM bit (BIT(7)) ie it does not support synchronous mode. 326 + * - SCFCR register does not have SCFCR_MCE bit. 327 + * - SCSPTR register has only bits SCSPTR_SPB2DT and SCSPTR_SPB2IO. 328 + */ 329 + [SCIx_RZV2H_SCIF_REGTYPE] = { 330 + .regs = { 331 + [SCSMR] = { 0x00, 16 }, 332 + [SCBRR] = { 0x02, 8 }, 333 + [SCSCR] = { 0x04, 16 }, 334 + [SCxTDR] = { 0x06, 8 }, 335 + [SCxSR] = { 0x08, 16 }, 336 + [SCxRDR] = { 0x0a, 8 }, 337 + [SCFCR] = { 0x0c, 16 }, 338 + [SCFDR] = { 0x0e, 16 }, 339 + [SCSPTR] = { 0x10, 16 }, 340 + [SCLSR] = { 0x12, 16 }, 341 + [SEMR] = { 0x14, 8 }, 342 + }, 343 + .fifosize = 16, 344 + .overrun_reg = SCLSR, 345 + .overrun_mask = SCLSR_ORER, 346 + .sampling_rate_mask = SCI_SR(32), 347 + .error_mask = SCIF_DEFAULT_ERROR_MASK, 348 + .error_clear = SCIF_ERROR_CLEAR, 349 + }, 350 + 351 + /* 321 352 * Common SH-3 SCIF definitions. 322 353 */ 323 354 [SCIx_SH3_SCIF_REGTYPE] = { ··· 788 757 } 789 758 sci_serial_out(port, SCPDR, data); 790 759 sci_serial_out(port, SCPCR, ctrl); 791 - } else if (sci_getreg(port, SCSPTR)->size) { 760 + } else if (sci_getreg(port, SCSPTR)->size && s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE) { 792 761 u16 status = sci_serial_in(port, SCSPTR); 793 762 794 763 /* RTS# is always output; and active low, unless autorts */ ··· 2155 2124 2156 2125 if (!(mctrl & TIOCM_RTS)) { 2157 2126 /* Disable Auto RTS */ 2158 - sci_serial_out(port, SCFCR, 2159 - sci_serial_in(port, SCFCR) & ~SCFCR_MCE); 2127 + if (s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE) 2128 + sci_serial_out(port, SCFCR, 2129 + sci_serial_in(port, SCFCR) & ~SCFCR_MCE); 2160 2130 2161 2131 /* Clear RTS */ 2162 2132 sci_set_rts(port, 0); ··· 2169 2137 } 2170 2138 2171 2139 /* Enable Auto RTS */ 2172 - sci_serial_out(port, SCFCR, 2173 - sci_serial_in(port, SCFCR) | SCFCR_MCE); 2140 + if (s->cfg->regtype != SCIx_RZV2H_SCIF_REGTYPE) 2141 + sci_serial_out(port, SCFCR, 2142 + sci_serial_in(port, SCFCR) | SCFCR_MCE); 2174 2143 } else { 2175 2144 /* Set RTS */ 2176 2145 sci_set_rts(port, 1); ··· 3258 3225 .compatible = "renesas,scif-r9a07g044", 3259 3226 .data = SCI_OF_DATA(PORT_SCIF, SCIx_RZ_SCIFA_REGTYPE), 3260 3227 }, 3228 + { 3229 + .compatible = "renesas,scif-r9a09g057", 3230 + .data = SCI_OF_DATA(PORT_SCIF, SCIx_RZV2H_SCIF_REGTYPE), 3231 + }, 3261 3232 /* Family-specific types */ 3262 3233 { 3263 3234 .compatible = "renesas,rcar-gen1-scif", ··· 3570 3533 return early_console_setup(device, PORT_SCIF); 3571 3534 } 3572 3535 3536 + static int __init rzv2hscif_early_console_setup(struct earlycon_device *device, 3537 + const char *opt) 3538 + { 3539 + port_cfg.regtype = SCIx_RZV2H_SCIF_REGTYPE; 3540 + return early_console_setup(device, PORT_SCIF); 3541 + } 3542 + 3573 3543 static int __init scifa_early_console_setup(struct earlycon_device *device, 3574 3544 const char *opt) 3575 3545 { ··· 3597 3553 OF_EARLYCON_DECLARE(scif, "renesas,scif", scif_early_console_setup); 3598 3554 OF_EARLYCON_DECLARE(scif, "renesas,scif-r7s9210", rzscifa_early_console_setup); 3599 3555 OF_EARLYCON_DECLARE(scif, "renesas,scif-r9a07g044", rzscifa_early_console_setup); 3556 + OF_EARLYCON_DECLARE(scif, "renesas,scif-r9a09g057", rzv2hscif_early_console_setup); 3600 3557 OF_EARLYCON_DECLARE(scifa, "renesas,scifa", scifa_early_console_setup); 3601 3558 OF_EARLYCON_DECLARE(scifb, "renesas,scifb", scifb_early_console_setup); 3602 3559 OF_EARLYCON_DECLARE(hscif, "renesas,hscif", hscif_early_console_setup);
+11 -26
drivers/tty/serial/sunsu.c
··· 1382 1382 1383 1383 static enum su_type su_get_type(struct device_node *dp) 1384 1384 { 1385 - struct device_node *ap = of_find_node_by_path("/aliases"); 1386 - enum su_type rc = SU_PORT_PORT; 1385 + struct device_node *ap __free(device_node) = 1386 + of_find_node_by_path("/aliases"); 1387 1387 1388 1388 if (ap) { 1389 1389 const char *keyb = of_get_property(ap, "keyboard", NULL); 1390 1390 const char *ms = of_get_property(ap, "mouse", NULL); 1391 - struct device_node *match; 1392 1391 1393 1392 if (keyb) { 1394 - match = of_find_node_by_path(keyb); 1393 + struct device_node *match __free(device_node) = 1394 + of_find_node_by_path(keyb); 1395 1395 1396 - /* 1397 - * The pointer is used as an identifier not 1398 - * as a pointer, we can drop the refcount on 1399 - * the of__node immediately after getting it. 1400 - */ 1401 - of_node_put(match); 1402 - 1403 - if (dp == match) { 1404 - rc = SU_PORT_KBD; 1405 - goto out; 1406 - } 1396 + if (dp == match) 1397 + return SU_PORT_KBD; 1407 1398 } 1408 1399 if (ms) { 1409 - match = of_find_node_by_path(ms); 1400 + struct device_node *match __free(device_node) = 1401 + of_find_node_by_path(ms); 1410 1402 1411 - of_node_put(match); 1412 - 1413 - if (dp == match) { 1414 - rc = SU_PORT_MS; 1415 - goto out; 1416 - } 1403 + if (dp == match) 1404 + return SU_PORT_MS; 1417 1405 } 1418 1406 } 1419 - 1420 - out: 1421 - of_node_put(ap); 1422 - return rc; 1407 + return SU_PORT_PORT; 1423 1408 } 1424 1409 1425 1410 static int su_probe(struct platform_device *op)
+1
drivers/tty/ttynull.c
··· 106 106 module_init(ttynull_init); 107 107 module_exit(ttynull_exit); 108 108 109 + MODULE_DESCRIPTION("NULL TTY driver"); 109 110 MODULE_LICENSE("GPL v2");
+1 -3
drivers/tty/vt/keyboard.c
··· 1033 1033 1034 1034 tasklet_disable(&keyboard_tasklet); 1035 1035 if (ledstate != -1U) 1036 - led_trigger_event(&trigger->trigger, 1037 - ledstate & trigger->mask ? 1038 - LED_FULL : LED_OFF); 1036 + led_set_brightness(cdev, ledstate & trigger->mask ? LED_FULL : LED_OFF); 1039 1037 tasklet_enable(&keyboard_tasklet); 1040 1038 1041 1039 return 0;
+4
include/linux/printk.h
··· 60 60 #define CONSOLE_LOGLEVEL_DEFAULT CONFIG_CONSOLE_LOGLEVEL_DEFAULT 61 61 #define CONSOLE_LOGLEVEL_QUIET CONFIG_CONSOLE_LOGLEVEL_QUIET 62 62 63 + int match_devname_and_update_preferred_console(const char *match, 64 + const char *name, 65 + const short idx); 66 + 63 67 extern int console_printk[]; 64 68 65 69 #define console_loglevel (console_printk[0])
+1
include/linux/serial_sci.h
··· 37 37 SCIx_SH7705_SCIF_REGTYPE, 38 38 SCIx_HSCIF_REGTYPE, 39 39 SCIx_RZ_SCIFA_REGTYPE, 40 + SCIx_RZV2H_SCIF_REGTYPE, 40 41 41 42 SCIx_NR_REGTYPES, 42 43 };
+1
kernel/printk/console_cmdline.h
··· 6 6 { 7 7 char name[16]; /* Name of the driver */ 8 8 int index; /* Minor dev. to use */ 9 + char devname[32]; /* DEVNAME:0.0 style device name */ 9 10 bool user_specified; /* Specified by command line vs. platform */ 10 11 char *options; /* Options for the driver */ 11 12 #ifdef CONFIG_A11Y_BRAILLE_CONSOLE
+88 -15
kernel/printk/printk.c
··· 2429 2429 console_set_on_cmdline = 1; 2430 2430 } 2431 2431 2432 - static int __add_preferred_console(const char *name, const short idx, char *options, 2432 + static int __add_preferred_console(const char *name, const short idx, 2433 + const char *devname, char *options, 2433 2434 char *brl_options, bool user_specified) 2434 2435 { 2435 2436 struct console_cmdline *c; 2436 2437 int i; 2437 2438 2439 + if (!name && !devname) 2440 + return -EINVAL; 2441 + 2438 2442 /* 2439 2443 * We use a signed short index for struct console for device drivers to 2440 2444 * indicate a not yet assigned index or port. However, a negative index 2441 - * value is not valid for preferred console. 2445 + * value is not valid when the console name and index are defined on 2446 + * the command line. 2442 2447 */ 2443 - if (idx < 0) 2448 + if (name && idx < 0) 2444 2449 return -EINVAL; 2445 2450 2446 2451 /* ··· 2453 2448 * if we have a slot free. 2454 2449 */ 2455 2450 for (i = 0, c = console_cmdline; 2456 - i < MAX_CMDLINECONSOLES && c->name[0]; 2451 + i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); 2457 2452 i++, c++) { 2458 - if (strcmp(c->name, name) == 0 && c->index == idx) { 2453 + if ((name && strcmp(c->name, name) == 0 && c->index == idx) || 2454 + (devname && strcmp(c->devname, devname) == 0)) { 2459 2455 if (!brl_options) 2460 2456 preferred_console = i; 2461 2457 set_user_specified(c, user_specified); ··· 2467 2461 return -E2BIG; 2468 2462 if (!brl_options) 2469 2463 preferred_console = i; 2470 - strscpy(c->name, name, sizeof(c->name)); 2464 + if (name) 2465 + strscpy(c->name, name); 2466 + if (devname) 2467 + strscpy(c->devname, devname); 2471 2468 c->options = options; 2472 2469 set_user_specified(c, user_specified); 2473 2470 braille_set_options(c, brl_options); ··· 2495 2486 */ 2496 2487 static int __init console_setup(char *str) 2497 2488 { 2498 - char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for "ttyS" */ 2499 - char *s, *options, *brl_options = NULL; 2489 + static_assert(sizeof(console_cmdline[0].devname) >= sizeof(console_cmdline[0].name) + 4); 2490 + char buf[sizeof(console_cmdline[0].devname)]; 2491 + char *brl_options = NULL; 2492 + char *ttyname = NULL; 2493 + char *devname = NULL; 2494 + char *options; 2495 + char *s; 2500 2496 int idx; 2501 2497 2502 2498 /* ··· 2510 2496 * for exactly this purpose. 2511 2497 */ 2512 2498 if (str[0] == 0 || strcmp(str, "null") == 0) { 2513 - __add_preferred_console("ttynull", 0, NULL, NULL, true); 2499 + __add_preferred_console("ttynull", 0, NULL, NULL, NULL, true); 2514 2500 return 1; 2515 2501 } 2516 2502 2517 2503 if (_braille_console_setup(&str, &brl_options)) 2518 2504 return 1; 2519 2505 2506 + /* For a DEVNAME:0.0 style console the character device is unknown early */ 2507 + if (strchr(str, ':')) 2508 + devname = buf; 2509 + else 2510 + ttyname = buf; 2511 + 2520 2512 /* 2521 2513 * Decode str into name, index, options. 2522 2514 */ 2523 - if (isdigit(str[0])) 2515 + if (ttyname && isdigit(str[0])) 2524 2516 scnprintf(buf, sizeof(buf), "ttyS%s", str); 2525 2517 else 2526 2518 strscpy(buf, str); ··· 2543 2523 #endif 2544 2524 2545 2525 for (s = buf; *s; s++) 2546 - if (isdigit(*s) || *s == ',') 2526 + if ((ttyname && isdigit(*s)) || *s == ',') 2547 2527 break; 2548 - idx = simple_strtoul(s, NULL, 10); 2528 + 2529 + /* @idx will get defined when devname matches. */ 2530 + if (devname) 2531 + idx = -1; 2532 + else 2533 + idx = simple_strtoul(s, NULL, 10); 2534 + 2549 2535 *s = 0; 2550 2536 2551 - __add_preferred_console(buf, idx, options, brl_options, true); 2537 + __add_preferred_console(ttyname, idx, devname, options, brl_options, true); 2552 2538 return 1; 2553 2539 } 2554 2540 __setup("console=", console_setup); ··· 2574 2548 */ 2575 2549 int add_preferred_console(const char *name, const short idx, char *options) 2576 2550 { 2577 - return __add_preferred_console(name, idx, options, NULL, false); 2551 + return __add_preferred_console(name, idx, NULL, options, NULL, false); 2552 + } 2553 + 2554 + /** 2555 + * match_devname_and_update_preferred_console - Update a preferred console 2556 + * when matching devname is found. 2557 + * @devname: DEVNAME:0.0 style device name 2558 + * @name: Name of the corresponding console driver, e.g. "ttyS" 2559 + * @idx: Console index, e.g. port number. 2560 + * 2561 + * The function checks whether a device with the given @devname is 2562 + * preferred via the console=DEVNAME:0.0 command line option. 2563 + * It fills the missing console driver name and console index 2564 + * so that a later register_console() call could find (match) 2565 + * and enable this device. 2566 + * 2567 + * It might be used when a driver subsystem initializes particular 2568 + * devices with already known DEVNAME:0.0 style names. And it 2569 + * could predict which console driver name and index this device 2570 + * would later get associated with. 2571 + * 2572 + * Return: 0 on success, negative error code on failure. 2573 + */ 2574 + int match_devname_and_update_preferred_console(const char *devname, 2575 + const char *name, 2576 + const short idx) 2577 + { 2578 + struct console_cmdline *c = console_cmdline; 2579 + int i; 2580 + 2581 + if (!devname || !strlen(devname) || !name || !strlen(name) || idx < 0) 2582 + return -EINVAL; 2583 + 2584 + for (i = 0; i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); 2585 + i++, c++) { 2586 + if (!strcmp(devname, c->devname)) { 2587 + pr_info("associate the preferred console \"%s\" with \"%s%d\"\n", 2588 + devname, name, idx); 2589 + strscpy(c->name, name); 2590 + c->index = idx; 2591 + return 0; 2592 + } 2593 + } 2594 + 2595 + return -ENOENT; 2578 2596 } 2579 2597 2580 2598 bool console_suspend_enabled = true; ··· 3388 3318 int i, err; 3389 3319 3390 3320 for (i = 0, c = console_cmdline; 3391 - i < MAX_CMDLINECONSOLES && c->name[0]; 3321 + i < MAX_CMDLINECONSOLES && (c->name[0] || c->devname[0]); 3392 3322 i++, c++) { 3323 + /* Console not yet initialized? */ 3324 + if (!c->name[0]) 3325 + continue; 3393 3326 if (c->user_specified != user_specified) 3394 3327 continue; 3395 3328 if (!newcon->match ||