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

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

Pull tty and serial driver updates from Greg KH:
"Here is the big set of tty and serial driver updates for 5.19-rc1.

Lots of tiny cleanups in here, the major stuff is:

- termbit cleanups and unification by Ilpo. A much needed change that
goes a long way to making things simpler for all of the different
arches

- tty documentation cleanups and movements to their own place in the
documentation tree

- old tty driver cleanups and fixes from Jiri to bring some existing
drivers into the modern world

- RS485 cleanups and unifications to make it easier for individual
drivers to support this mode instead of having to duplicate logic
in each driver

- Lots of 8250 driver updates and additions

- new device id additions

- n_gsm continued fixes and cleanups

- other minor serial driver updates and cleanups

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

* tag 'tty-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (166 commits)
tty: Rework receive flow control char logic
pcmcia: synclink_cs: Don't allow CS5-6
serial: stm32-usart: Correct CSIZE, bits, and parity
serial: st-asc: Sanitize CSIZE and correct PARENB for CS7
serial: sifive: Sanitize CSIZE and c_iflag
serial: sh-sci: Don't allow CS5-6
serial: txx9: Don't allow CS5-6
serial: rda-uart: Don't allow CS5-6
serial: digicolor-usart: Don't allow CS5-6
serial: uartlite: Fix BRKINT clearing
serial: cpm_uart: Fix build error without CONFIG_SERIAL_CPM_CONSOLE
serial: core: Do stop_rx in suspend path for console if console_suspend is disabled
tty: serial: qcom-geni-serial: Remove uart frequency table. Instead, find suitable frequency with call to clk_round_rate.
dt-bindings: serial: renesas,em-uart: Add RZ/V2M clock to access the registers
serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485
Revert "serial: 8250_mtk: Make sure to select the right FEATURE_SEL"
serial: msm_serial: disable interrupts in __msm_console_write()
serial: meson: acquire port->lock in startup()
serial: 8250_dw: Use dev_err_probe()
serial: 8250_dw: Use devm_add_action_or_reset()
...

+3166 -2453
+3 -1
Documentation/devicetree/bindings/serial/fsl-lpuart.yaml
··· 23 23 - fsl,imx8qxp-lpuart 24 24 - fsl,imxrt1050-lpuart 25 25 - items: 26 - - const: fsl,imx8ulp-lpuart 26 + - enum: 27 + - fsl,imx93-lpuart 28 + - fsl,imx8ulp-lpuart 27 29 - const: fsl,imx7ulp-lpuart 28 30 - items: 29 31 - enum:
+86
Documentation/devicetree/bindings/serial/qcom,serial-geni-qcom.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: "http://devicetree.org/schemas/serial/qcom,serial-geni-qcom.yaml#" 5 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 6 + 7 + title: Qualcomm Geni based QUP UART interface 8 + 9 + maintainers: 10 + - Andy Gross <agross@kernel.org> 11 + - Bjorn Andersson <bjorn.andersson@linaro.org> 12 + 13 + allOf: 14 + - $ref: /schemas/serial/serial.yaml# 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - qcom,geni-uart 20 + - qcom,geni-debug-uart 21 + 22 + clocks: 23 + maxItems: 1 24 + 25 + clock-names: 26 + const: se 27 + 28 + interconnects: 29 + maxItems: 2 30 + 31 + interconnect-names: 32 + items: 33 + - const: qup-core 34 + - const: qup-config 35 + 36 + interrupts: 37 + minItems: 1 38 + items: 39 + - description: UART core irq 40 + - description: Wakeup irq (RX GPIO) 41 + 42 + operating-points-v2: true 43 + 44 + pinctrl-0: true 45 + pinctrl-1: true 46 + 47 + pinctrl-names: 48 + minItems: 1 49 + items: 50 + - const: default 51 + - const: sleep 52 + 53 + power-domains: 54 + maxItems: 1 55 + 56 + reg: 57 + maxItems: 1 58 + 59 + required: 60 + - compatible 61 + - clocks 62 + - clock-names 63 + - interrupts 64 + - reg 65 + 66 + unevaluatedProperties: false 67 + 68 + examples: 69 + - | 70 + #include <dt-bindings/interrupt-controller/arm-gic.h> 71 + #include <dt-bindings/clock/qcom,gcc-sc7180.h> 72 + #include <dt-bindings/interconnect/qcom,sc7180.h> 73 + 74 + serial@a88000 { 75 + compatible = "qcom,geni-uart"; 76 + reg = <0xa88000 0x7000>; 77 + interrupts = <GIC_SPI 355 IRQ_TYPE_LEVEL_HIGH>; 78 + clock-names = "se"; 79 + clocks = <&gcc GCC_QUPV3_WRAP0_S0_CLK>; 80 + pinctrl-0 = <&qup_uart0_default>; 81 + pinctrl-names = "default"; 82 + interconnects = <&qup_virt MASTER_QUP_CORE_0 0 &qup_virt SLAVE_QUP_CORE_0 0>, 83 + <&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>; 84 + interconnect-names = "qup-core", "qup-config"; 85 + }; 86 + ...
+31 -6
Documentation/devicetree/bindings/serial/renesas,em-uart.yaml
··· 9 9 maintainers: 10 10 - Magnus Damm <magnus.damm@gmail.com> 11 11 12 - allOf: 13 - - $ref: serial.yaml# 14 - 15 12 properties: 16 13 compatible: 17 - const: renesas,em-uart 14 + oneOf: 15 + - items: 16 + - enum: 17 + - renesas,r9a09g011-uart # RZ/V2M 18 + - const: renesas,em-uart # generic EMMA Mobile compatible UART 19 + 20 + - items: 21 + - const: renesas,em-uart # generic EMMA Mobile compatible UART 18 22 19 23 reg: 20 24 maxItems: 1 ··· 27 23 maxItems: 1 28 24 29 25 clocks: 30 - maxItems: 1 26 + minItems: 1 27 + items: 28 + - description: UART functional clock 29 + - description: Internal clock to access the registers 31 30 32 31 clock-names: 33 - const: sclk 32 + minItems: 1 33 + items: 34 + - const: sclk 35 + - const: pclk 36 + 37 + allOf: 38 + - $ref: serial.yaml# 39 + 40 + - if: 41 + properties: 42 + compatible: 43 + contains: 44 + const: renesas,r9a09g011-uart 45 + then: 46 + properties: 47 + clocks: 48 + minItems: 2 49 + clock-names: 50 + minItems: 2 34 51 35 52 required: 36 53 - compatible
+8 -1
Documentation/devicetree/bindings/serial/renesas,hscif.yaml
··· 51 51 - renesas,hscif-r8a77980 # R-Car V3H 52 52 - renesas,hscif-r8a77990 # R-Car E3 53 53 - renesas,hscif-r8a77995 # R-Car D3 54 - - renesas,hscif-r8a779a0 # R-Car V3U 55 54 - const: renesas,rcar-gen3-hscif # R-Car Gen3 and RZ/G2 55 + - const: renesas,hscif # generic HSCIF compatible UART 56 + 57 + - items: 58 + - enum: 59 + - renesas,hscif-r8a779a0 # R-Car V3U 60 + - renesas,hscif-r8a779g0 # R-Car V4H 61 + - const: renesas,rcar-gen4-hscif # R-Car Gen4 56 62 - const: renesas,hscif # generic HSCIF compatible UART 57 63 58 64 reg: ··· 119 113 enum: 120 114 - renesas,rcar-gen2-hscif 121 115 - renesas,rcar-gen3-hscif 116 + - renesas,rcar-gen4-hscif 122 117 then: 123 118 required: 124 119 - resets
+1 -1
Documentation/devicetree/bindings/serial/renesas,scif.yaml
··· 60 60 - renesas,scif-r8a77980 # R-Car V3H 61 61 - renesas,scif-r8a77990 # R-Car E3 62 62 - renesas,scif-r8a77995 # R-Car D3 63 - - renesas,scif-r8a779a0 # R-Car V3U 64 63 - const: renesas,rcar-gen3-scif # R-Car Gen3 and RZ/G2 65 64 - const: renesas,scif # generic SCIF compatible UART 66 65 67 66 - items: 68 67 - enum: 68 + - renesas,scif-r8a779a0 # R-Car V3U 69 69 - renesas,scif-r8a779f0 # R-Car S4-8 70 70 - const: renesas,rcar-gen4-scif # R-Car Gen4 71 71 - const: renesas,scif # generic SCIF compatible UART
+5
Documentation/devicetree/bindings/serial/rs485.yaml
··· 33 33 description: drive RTS low when sending (default is high). 34 34 $ref: /schemas/types.yaml#/definitions/flag 35 35 36 + rs485-rx-active-high: 37 + description: Polarity of receiver enable signal (when separate from RTS). 38 + True indicates active high (default is low). 39 + $ref: /schemas/types.yaml#/definitions/flag 40 + 36 41 linux,rs485-enabled-at-boot-time: 37 42 description: enables the rs485 feature at boot time. It can be disabled 38 43 later with proper ioctl.
+4 -1
Documentation/devicetree/bindings/serial/socionext,uniphier-uart.yaml
··· 20 20 maxItems: 1 21 21 22 22 clocks: 23 - minItems: 1 23 + maxItems: 1 24 + 25 + resets: 26 + maxItems: 1 24 27 25 28 auto-flow-control: 26 29 description: enable automatic flow control support.
+1
Documentation/driver-api/index.rst
··· 101 101 surface_aggregator/index 102 102 switchtec 103 103 sync_file 104 + tty/index 104 105 vfio-mediated-device 105 106 vfio 106 107 vfio-pci-device-specific-driver-acceptance
+1 -1
Documentation/driver-api/serial/driver.rst
··· 311 311 This call must not sleep 312 312 313 313 set_ldisc(port,termios) 314 - Notifier for discipline change. See Documentation/tty/tty_ldisc.rst. 314 + Notifier for discipline change. See ../tty/tty_ldisc.rst. 315 315 316 316 Locking: caller holds tty_port->mutex 317 317
-2
Documentation/driver-api/serial/index.rst
··· 16 16 .. toctree:: 17 17 :maxdepth: 1 18 18 19 - moxa-smartio 20 - n_gsm 21 19 serial-iso7816 22 20 serial-rs485 23 21
Documentation/driver-api/serial/moxa-smartio.rst Documentation/driver-api/tty/moxa-smartio.rst
-159
Documentation/driver-api/serial/n_gsm.rst
··· 1 - ============================== 2 - GSM 0710 tty multiplexor HOWTO 3 - ============================== 4 - 5 - This line discipline implements the GSM 07.10 multiplexing protocol 6 - detailed in the following 3GPP document: 7 - 8 - https://www.3gpp.org/ftp/Specs/archive/07_series/07.10/0710-720.zip 9 - 10 - This document give some hints on how to use this driver with GPRS and 3G 11 - modems connected to a physical serial port. 12 - 13 - How to use it 14 - ------------- 15 - 1. config initiator 16 - ^^^^^^^^^^^^^^^^^^^^^ 17 - 18 - 1.1 initialize the modem in 0710 mux mode (usually AT+CMUX= command) through 19 - its serial port. Depending on the modem used, you can pass more or less 20 - parameters to this command. 21 - 22 - 1.2 switch the serial line to using the n_gsm line discipline by using 23 - TIOCSETD ioctl. 24 - 25 - 1.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl. 26 - 27 - 1.4 obtain base gsmtty number for the used serial port. 28 - 29 - Major parts of the initialization program : 30 - (a good starting point is util-linux-ng/sys-utils/ldattach.c):: 31 - 32 - #include <stdio.h> 33 - #include <stdint.h> 34 - #include <linux/gsmmux.h> 35 - #include <linux/tty.h> 36 - #define DEFAULT_SPEED B115200 37 - #define SERIAL_PORT /dev/ttyS0 38 - 39 - int ldisc = N_GSM0710; 40 - struct gsm_config c; 41 - struct termios configuration; 42 - uint32_t first; 43 - 44 - /* open the serial port connected to the modem */ 45 - fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY); 46 - 47 - /* configure the serial port : speed, flow control ... */ 48 - 49 - /* send the AT commands to switch the modem to CMUX mode 50 - and check that it's successful (should return OK) */ 51 - write(fd, "AT+CMUX=0\r", 10); 52 - 53 - /* experience showed that some modems need some time before 54 - being able to answer to the first MUX packet so a delay 55 - may be needed here in some case */ 56 - sleep(3); 57 - 58 - /* use n_gsm line discipline */ 59 - ioctl(fd, TIOCSETD, &ldisc); 60 - 61 - /* get n_gsm configuration */ 62 - ioctl(fd, GSMIOC_GETCONF, &c); 63 - /* we are initiator and need encoding 0 (basic) */ 64 - c.initiator = 1; 65 - c.encapsulation = 0; 66 - /* our modem defaults to a maximum size of 127 bytes */ 67 - c.mru = 127; 68 - c.mtu = 127; 69 - /* set the new configuration */ 70 - ioctl(fd, GSMIOC_SETCONF, &c); 71 - /* get first gsmtty device node */ 72 - ioctl(fd, GSMIOC_GETFIRST, &first); 73 - printf("first muxed line: /dev/gsmtty%i\n", first); 74 - 75 - /* and wait for ever to keep the line discipline enabled */ 76 - daemon(0,0); 77 - pause(); 78 - 79 - 1.5 use these devices as plain serial ports. 80 - 81 - for example, it's possible: 82 - 83 - - and to use gnokii to send / receive SMS on ttygsm1 84 - - to use ppp to establish a datalink on ttygsm2 85 - 86 - 1.6 first close all virtual ports before closing the physical port. 87 - 88 - Note that after closing the physical port the modem is still in multiplexing 89 - mode. This may prevent a successful re-opening of the port later. To avoid 90 - this situation either reset the modem if your hardware allows that or send 91 - a disconnect command frame manually before initializing the multiplexing mode 92 - for the second time. The byte sequence for the disconnect command frame is:: 93 - 94 - 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9. 95 - 96 - 2. config requester 97 - ^^^^^^^^^^^^^^^^^^^^^ 98 - 99 - 2.1 receive string "AT+CMUX= command" through its serial port,initialize 100 - mux mode config 101 - 102 - 2.2 switch the serial line to using the n_gsm line discipline by using 103 - TIOCSETD ioctl. 104 - 105 - 2.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl. 106 - 107 - 2.4 obtain base gsmtty number for the used serial port:: 108 - 109 - #include <stdio.h> 110 - #include <stdint.h> 111 - #include <linux/gsmmux.h> 112 - #include <linux/tty.h> 113 - #define DEFAULT_SPEED B115200 114 - #define SERIAL_PORT /dev/ttyS0 115 - 116 - int ldisc = N_GSM0710; 117 - struct gsm_config c; 118 - struct termios configuration; 119 - uint32_t first; 120 - 121 - /* open the serial port */ 122 - fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY); 123 - 124 - /* configure the serial port : speed, flow control ... */ 125 - 126 - /* get serial data and check "AT+CMUX=command" parameter ... */ 127 - 128 - /* use n_gsm line discipline */ 129 - ioctl(fd, TIOCSETD, &ldisc); 130 - 131 - /* get n_gsm configuration */ 132 - ioctl(fd, GSMIOC_GETCONF, &c); 133 - /* we are requester and need encoding 0 (basic) */ 134 - c.initiator = 0; 135 - c.encapsulation = 0; 136 - /* our modem defaults to a maximum size of 127 bytes */ 137 - c.mru = 127; 138 - c.mtu = 127; 139 - /* set the new configuration */ 140 - ioctl(fd, GSMIOC_SETCONF, &c); 141 - /* get first gsmtty device node */ 142 - ioctl(fd, GSMIOC_GETFIRST, &first); 143 - printf("first muxed line: /dev/gsmtty%i\n", first); 144 - 145 - /* and wait for ever to keep the line discipline enabled */ 146 - daemon(0,0); 147 - pause(); 148 - 149 - Additional Documentation 150 - ------------------------ 151 - More practical details on the protocol and how it's supported by industrial 152 - modems can be found in the following documents : 153 - 154 - - http://www.telit.com/module/infopool/download.php?id=616 155 - - http://www.u-blox.com/images/downloads/Product_Docs/LEON-G100-G200-MuxImplementation_ApplicationNote_%28GSM%20G1-CS-10002%29.pdf 156 - - http://www.sierrawireless.com/Support/Downloads/AirPrime/WMP_Series/~/media/Support_Downloads/AirPrime/Application_notes/CMUX_Feature_Application_Note-Rev004.ashx 157 - - http://wm.sim.com/sim/News/photo/2010721161442.pdf 158 - 159 - 11-03-08 - Eric Bénard - <eric@eukrea.com>
+153
Documentation/driver-api/tty/n_gsm.rst
··· 1 + ============================== 2 + GSM 0710 tty multiplexor HOWTO 3 + ============================== 4 + 5 + .. contents:: :local: 6 + 7 + This line discipline implements the GSM 07.10 multiplexing protocol 8 + detailed in the following 3GPP document: 9 + 10 + https://www.3gpp.org/ftp/Specs/archive/07_series/07.10/0710-720.zip 11 + 12 + This document give some hints on how to use this driver with GPRS and 3G 13 + modems connected to a physical serial port. 14 + 15 + How to use it 16 + ============= 17 + 18 + Config Initiator 19 + ---------------- 20 + 21 + #. Initialize the modem in 0710 mux mode (usually ``AT+CMUX=`` command) through 22 + its serial port. Depending on the modem used, you can pass more or less 23 + parameters to this command. 24 + 25 + #. Switch the serial line to using the n_gsm line discipline by using 26 + ``TIOCSETD`` ioctl. 27 + 28 + #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl. 29 + 30 + #. Obtain base gsmtty number for the used serial port. 31 + 32 + Major parts of the initialization program 33 + (a good starting point is util-linux-ng/sys-utils/ldattach.c):: 34 + 35 + #include <stdio.h> 36 + #include <stdint.h> 37 + #include <linux/gsmmux.h> 38 + #include <linux/tty.h> 39 + 40 + #define DEFAULT_SPEED B115200 41 + #define SERIAL_PORT /dev/ttyS0 42 + 43 + int ldisc = N_GSM0710; 44 + struct gsm_config c; 45 + struct termios configuration; 46 + uint32_t first; 47 + 48 + /* open the serial port connected to the modem */ 49 + fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY); 50 + 51 + /* configure the serial port : speed, flow control ... */ 52 + 53 + /* send the AT commands to switch the modem to CMUX mode 54 + and check that it's successful (should return OK) */ 55 + write(fd, "AT+CMUX=0\r", 10); 56 + 57 + /* experience showed that some modems need some time before 58 + being able to answer to the first MUX packet so a delay 59 + may be needed here in some case */ 60 + sleep(3); 61 + 62 + /* use n_gsm line discipline */ 63 + ioctl(fd, TIOCSETD, &ldisc); 64 + 65 + /* get n_gsm configuration */ 66 + ioctl(fd, GSMIOC_GETCONF, &c); 67 + /* we are initiator and need encoding 0 (basic) */ 68 + c.initiator = 1; 69 + c.encapsulation = 0; 70 + /* our modem defaults to a maximum size of 127 bytes */ 71 + c.mru = 127; 72 + c.mtu = 127; 73 + /* set the new configuration */ 74 + ioctl(fd, GSMIOC_SETCONF, &c); 75 + /* get first gsmtty device node */ 76 + ioctl(fd, GSMIOC_GETFIRST, &first); 77 + printf("first muxed line: /dev/gsmtty%i\n", first); 78 + 79 + /* and wait for ever to keep the line discipline enabled */ 80 + daemon(0,0); 81 + pause(); 82 + 83 + #. Use these devices as plain serial ports. 84 + 85 + For example, it's possible: 86 + 87 + - to use *gnokii* to send / receive SMS on ``ttygsm1`` 88 + - to use *ppp* to establish a datalink on ``ttygsm2`` 89 + 90 + #. First close all virtual ports before closing the physical port. 91 + 92 + Note that after closing the physical port the modem is still in multiplexing 93 + mode. This may prevent a successful re-opening of the port later. To avoid 94 + this situation either reset the modem if your hardware allows that or send 95 + a disconnect command frame manually before initializing the multiplexing mode 96 + for the second time. The byte sequence for the disconnect command frame is:: 97 + 98 + 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9 99 + 100 + Config Requester 101 + ---------------- 102 + 103 + #. Receive ``AT+CMUX=`` command through its serial port, initialize mux mode 104 + config. 105 + 106 + #. Switch the serial line to using the *n_gsm* line discipline by using 107 + ``TIOCSETD`` ioctl. 108 + 109 + #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl. 110 + 111 + #. Obtain base gsmtty number for the used serial port:: 112 + 113 + #include <stdio.h> 114 + #include <stdint.h> 115 + #include <linux/gsmmux.h> 116 + #include <linux/tty.h> 117 + #define DEFAULT_SPEED B115200 118 + #define SERIAL_PORT /dev/ttyS0 119 + 120 + int ldisc = N_GSM0710; 121 + struct gsm_config c; 122 + struct termios configuration; 123 + uint32_t first; 124 + 125 + /* open the serial port */ 126 + fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY); 127 + 128 + /* configure the serial port : speed, flow control ... */ 129 + 130 + /* get serial data and check "AT+CMUX=command" parameter ... */ 131 + 132 + /* use n_gsm line discipline */ 133 + ioctl(fd, TIOCSETD, &ldisc); 134 + 135 + /* get n_gsm configuration */ 136 + ioctl(fd, GSMIOC_GETCONF, &c); 137 + /* we are requester and need encoding 0 (basic) */ 138 + c.initiator = 0; 139 + c.encapsulation = 0; 140 + /* our modem defaults to a maximum size of 127 bytes */ 141 + c.mru = 127; 142 + c.mtu = 127; 143 + /* set the new configuration */ 144 + ioctl(fd, GSMIOC_SETCONF, &c); 145 + /* get first gsmtty device node */ 146 + ioctl(fd, GSMIOC_GETFIRST, &first); 147 + printf("first muxed line: /dev/gsmtty%i\n", first); 148 + 149 + /* and wait for ever to keep the line discipline enabled */ 150 + daemon(0,0); 151 + pause(); 152 + 153 + 11-03-08 - Eric Bénard - <eric@eukrea.com>
+25
Documentation/firmware-guide/acpi/enumeration.rst
··· 389 389 See Documentation/firmware-guide/acpi/gpio-properties.rst for more information 390 390 about the _DSD binding related to GPIOs. 391 391 392 + RS-485 support 393 + ============== 394 + 395 + ACPI _DSD (Device Specific Data) can be used to describe RS-485 capability 396 + of UART. 397 + 398 + For example:: 399 + 400 + Device (DEV) 401 + { 402 + ... 403 + 404 + // ACPI 5.1 _DSD used for RS-485 capabilities 405 + Name (_DSD, Package () 406 + { 407 + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), 408 + Package () 409 + { 410 + Package () {"rs485-rts-active-low", Zero}, 411 + Package () {"rs485-rx-active-high", Zero}, 412 + Package () {"rs485-rx-during-tx", Zero}, 413 + } 414 + }) 415 + ... 416 + 392 417 MFD devices 393 418 =========== 394 419
-1
Documentation/index.rst
··· 136 136 misc-devices/index 137 137 scheduler/index 138 138 mhi/index 139 - tty/index 140 139 peci/index 141 140 142 141 Architecture-agnostic documentation
+1
Documentation/misc-devices/index.rst
··· 25 25 isl29003 26 26 lis3lv02d 27 27 max6875 28 + oxsemi-tornado 28 29 pci-endpoint-test 29 30 spear-pcie-gadget 30 31 uacce
+131
Documentation/misc-devices/oxsemi-tornado.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ==================================================================== 4 + Notes on Oxford Semiconductor PCIe (Tornado) 950 serial port devices 5 + ==================================================================== 6 + 7 + Oxford Semiconductor PCIe (Tornado) 950 serial port devices are driven 8 + by a fixed 62.5MHz clock input derived from the 100MHz PCI Express clock. 9 + 10 + The baud rate produced by the baud generator is obtained from this input 11 + frequency by dividing it by the clock prescaler, which can be set to any 12 + value from 1 to 63.875 in increments of 0.125, and then the usual 16-bit 13 + divisor is used as with the original 8250, to divide the frequency by a 14 + value from 1 to 65535. Finally a programmable oversampling rate is used 15 + that can take any value from 4 to 16 to divide the frequency further and 16 + determine the actual baud rate used. Baud rates from 15625000bps down 17 + to 0.933bps can be obtained this way. 18 + 19 + By default the oversampling rate is set to 16 and the clock prescaler is 20 + set to 33.875, meaning that the frequency to be used as the reference 21 + for the usual 16-bit divisor is 115313.653, which is close enough to the 22 + frequency of 115200 used by the original 8250 for the same values to be 23 + used for the divisor to obtain the requested baud rates by software that 24 + is unaware of the extra clock controls available. 25 + 26 + The oversampling rate is programmed with the TCR register and the clock 27 + prescaler is programmed with the CPR/CPR2 register pair [OX200]_ [OX952]_ 28 + [OX954]_ [OX958]_. To switch away from the default value of 33.875 for 29 + the prescaler the enhanced mode has to be explicitly enabled though, by 30 + setting bit 4 of the EFR. In that mode setting bit 7 in the MCR enables 31 + the prescaler or otherwise it is bypassed as if the value of 1 was used. 32 + Additionally writing any value to CPR clears CPR2 for compatibility with 33 + old software written for older conventional PCI Oxford Semiconductor 34 + devices that do not have the extra prescaler's 9th bit in CPR2, so the 35 + CPR/CPR2 register pair has to be programmed in the right order. 36 + 37 + By using these parameters rates from 15625000bps down to 1bps can be 38 + obtained, with either exact or highly-accurate actual bit rates for 39 + standard and many non-standard rates. 40 + 41 + Here are the figures for the standard and some non-standard baud rates 42 + (including those quoted in Oxford Semiconductor documentation), giving 43 + the requested rate (r), the actual rate yielded (a) and its deviation 44 + from the requested rate (d), and the values of the oversampling rate 45 + (tcr), the clock prescaler (cpr) and the divisor (div) produced by the 46 + new ``get_divisor`` handler: 47 + 48 + :: 49 + 50 + r: 15625000, a: 15625000.00, d: 0.0000%, tcr: 4, cpr: 1.000, div: 1 51 + r: 12500000, a: 12500000.00, d: 0.0000%, tcr: 5, cpr: 1.000, div: 1 52 + r: 10416666, a: 10416666.67, d: 0.0000%, tcr: 6, cpr: 1.000, div: 1 53 + r: 8928571, a: 8928571.43, d: 0.0000%, tcr: 7, cpr: 1.000, div: 1 54 + r: 7812500, a: 7812500.00, d: 0.0000%, tcr: 8, cpr: 1.000, div: 1 55 + r: 4000000, a: 4000000.00, d: 0.0000%, tcr: 5, cpr: 3.125, div: 1 56 + r: 3686400, a: 3676470.59, d: -0.2694%, tcr: 8, cpr: 2.125, div: 1 57 + r: 3500000, a: 3496503.50, d: -0.0999%, tcr: 13, cpr: 1.375, div: 1 58 + r: 3000000, a: 2976190.48, d: -0.7937%, tcr: 14, cpr: 1.500, div: 1 59 + r: 2500000, a: 2500000.00, d: 0.0000%, tcr: 10, cpr: 2.500, div: 1 60 + r: 2000000, a: 2000000.00, d: 0.0000%, tcr: 10, cpr: 3.125, div: 1 61 + r: 1843200, a: 1838235.29, d: -0.2694%, tcr: 16, cpr: 2.125, div: 1 62 + r: 1500000, a: 1492537.31, d: -0.4975%, tcr: 5, cpr: 8.375, div: 1 63 + r: 1152000, a: 1152073.73, d: 0.0064%, tcr: 14, cpr: 3.875, div: 1 64 + r: 921600, a: 919117.65, d: -0.2694%, tcr: 16, cpr: 2.125, div: 2 65 + r: 576000, a: 576036.87, d: 0.0064%, tcr: 14, cpr: 3.875, div: 2 66 + r: 460800, a: 460829.49, d: 0.0064%, tcr: 7, cpr: 3.875, div: 5 67 + r: 230400, a: 230414.75, d: 0.0064%, tcr: 14, cpr: 3.875, div: 5 68 + r: 115200, a: 115207.37, d: 0.0064%, tcr: 14, cpr: 1.250, div: 31 69 + r: 57600, a: 57603.69, d: 0.0064%, tcr: 8, cpr: 3.875, div: 35 70 + r: 38400, a: 38402.46, d: 0.0064%, tcr: 14, cpr: 3.875, div: 30 71 + r: 19200, a: 19201.23, d: 0.0064%, tcr: 8, cpr: 3.875, div: 105 72 + r: 9600, a: 9600.06, d: 0.0006%, tcr: 9, cpr: 1.125, div: 643 73 + r: 4800, a: 4799.98, d: -0.0004%, tcr: 7, cpr: 2.875, div: 647 74 + r: 2400, a: 2400.02, d: 0.0008%, tcr: 9, cpr: 2.250, div: 1286 75 + r: 1200, a: 1200.00, d: 0.0000%, tcr: 14, cpr: 2.875, div: 1294 76 + r: 300, a: 300.00, d: 0.0000%, tcr: 11, cpr: 2.625, div: 7215 77 + r: 200, a: 200.00, d: 0.0000%, tcr: 16, cpr: 1.250, div: 15625 78 + r: 150, a: 150.00, d: 0.0000%, tcr: 13, cpr: 2.250, div: 14245 79 + r: 134, a: 134.00, d: 0.0000%, tcr: 11, cpr: 2.625, div: 16153 80 + r: 110, a: 110.00, d: 0.0000%, tcr: 12, cpr: 1.000, div: 47348 81 + r: 75, a: 75.00, d: 0.0000%, tcr: 4, cpr: 5.875, div: 35461 82 + r: 50, a: 50.00, d: 0.0000%, tcr: 16, cpr: 1.250, div: 62500 83 + r: 25, a: 25.00, d: 0.0000%, tcr: 16, cpr: 2.500, div: 62500 84 + r: 4, a: 4.00, d: 0.0000%, tcr: 16, cpr: 20.000, div: 48828 85 + r: 2, a: 2.00, d: 0.0000%, tcr: 16, cpr: 40.000, div: 48828 86 + r: 1, a: 1.00, d: 0.0000%, tcr: 16, cpr: 63.875, div: 61154 87 + 88 + With the baud base set to 15625000 and the unsigned 16-bit UART_DIV_MAX 89 + limitation imposed by ``serial8250_get_baud_rate`` standard baud rates 90 + below 300bps become unavailable in the regular way, e.g. the rate of 91 + 200bps requires the baud base to be divided by 78125 and that is beyond 92 + the unsigned 16-bit range. The historic spd_cust feature can still be 93 + used by encoding the values for, the prescaler, the oversampling rate 94 + and the clock divisor (DLM/DLL) as follows to obtain such rates if so 95 + required: 96 + 97 + :: 98 + 99 + 31 29 28 20 19 16 15 0 100 + +-----+-----------------+-------+-------------------------------+ 101 + |0 0 0| CPR2:CPR | TCR | DLM:DLL | 102 + +-----+-----------------+-------+-------------------------------+ 103 + 104 + Use a value such encoded for the ``custom_divisor`` field along with the 105 + ASYNC_SPD_CUST flag set in the ``flags`` field in ``struct serial_struct`` 106 + passed with the TIOCSSERIAL ioctl(2), such as with the setserial(8) 107 + utility and its ``divisor`` and ``spd_cust`` parameters, and then select 108 + the baud rate of 38400bps. Note that the value of 0 in TCR sets the 109 + oversampling rate to 16 and prescaler values below 1 in CPR2/CPR are 110 + clamped by the driver to 1. 111 + 112 + For example the value of 0x1f4004e2 will set CPR2/CPR, TCR and DLM/DLL 113 + respectively to 0x1f4, 0x0 and 0x04e2, choosing the prescaler value, 114 + the oversampling rate and the clock divisor of 62.500, 16 and 1250 115 + respectively. These parameters will set the baud rate for the serial 116 + port to 62500000 / 62.500 / 1250 / 16 = 50bps. 117 + 118 + Maciej W. Rozycki <macro@orcam.me.uk> 119 + 120 + .. [OX200] "OXPCIe200 PCI Express Multi-Port Bridge", Oxford Semiconductor, 121 + Inc., DS-0045, 10 Nov 2008, Section "950 Mode", pp. 64-65 122 + 123 + .. [OX952] "OXPCIe952 PCI Express Bridge to Dual Serial & Parallel Port", 124 + Oxford Semiconductor, Inc., DS-0046, Mar 06 08, Section "950 Mode", 125 + p. 20 126 + 127 + .. [OX954] "OXPCIe954 PCI Express Bridge to Quad Serial Port", Oxford 128 + Semiconductor, Inc., DS-0047, Feb 08, Section "950 Mode", p. 20 129 + 130 + .. [OX958] "OXPCIe958 PCI Express Bridge to Octal Serial Port", Oxford 131 + Semiconductor, Inc., DS-0048, Feb 08, Section "950 Mode", p. 20
+16 -6
Documentation/tty/index.rst Documentation/driver-api/tty/index.rst
··· 36 36 tty_struct 37 37 tty_ldisc 38 38 tty_buffer 39 - n_tty 40 39 tty_internals 41 40 42 41 Writing TTY Driver 43 42 ================== 44 43 45 44 Before one starts writing a TTY driver, they must consider 46 - :doc:`Serial <../driver-api/serial/driver>` and :doc:`USB Serial 47 - <../usb/usb-serial>` layers 48 - first. Drivers for serial devices can often use one of these specific layers to 49 - implement a serial driver. Only special devices should be handled directly by 50 - the TTY Layer. If you are about to write such a driver, read on. 45 + :doc:`Serial <../serial/driver>` and :doc:`USB Serial <../../usb/usb-serial>` 46 + layers first. Drivers for serial devices can often use one of these specific 47 + layers to implement a serial driver. Only special devices should be handled 48 + directly by the TTY Layer. If you are about to write such a driver, read on. 51 49 52 50 A *typical* sequence a TTY driver performs is as follows: 53 51 ··· 59 61 Steps regarding driver, i.e. 1., 3., and 5. are described in detail in 60 62 :doc:`tty_driver`. For the other two (devices handling), look into 61 63 :doc:`tty_port`. 64 + 65 + Other Documentation 66 + =================== 67 + 68 + Miscellaneous documentation can be further found in these documents: 69 + 70 + .. toctree:: 71 + :maxdepth: 2 72 + 73 + moxa-smartio 74 + n_gsm 75 + n_tty
Documentation/tty/n_tty.rst Documentation/driver-api/tty/n_tty.rst
Documentation/tty/tty_buffer.rst Documentation/driver-api/tty/tty_buffer.rst
Documentation/tty/tty_driver.rst Documentation/driver-api/tty/tty_driver.rst
Documentation/tty/tty_internals.rst Documentation/driver-api/tty/tty_internals.rst
Documentation/tty/tty_ldisc.rst Documentation/driver-api/tty/tty_ldisc.rst
Documentation/tty/tty_port.rst Documentation/driver-api/tty/tty_port.rst
Documentation/tty/tty_struct.rst Documentation/driver-api/tty/tty_struct.rst
+1 -1
MAINTAINERS
··· 13411 13411 MOXA SMARTIO/INDUSTIO/INTELLIO SERIAL CARD 13412 13412 M: Jiri Slaby <jirislaby@kernel.org> 13413 13413 S: Maintained 13414 - F: Documentation/driver-api/serial/moxa-smartio.rst 13414 + F: Documentation/driver-api/tty/moxa-smartio.rst 13415 13415 F: drivers/tty/mxser.* 13416 13416 13417 13417 MR800 AVERMEDIA USB FM RADIO DRIVER
+79 -135
arch/alpha/include/uapi/asm/termbits.h
··· 2 2 #ifndef _ALPHA_TERMBITS_H 3 3 #define _ALPHA_TERMBITS_H 4 4 5 - #include <linux/posix_types.h> 5 + #include <asm-generic/termbits-common.h> 6 6 7 - typedef unsigned char cc_t; 8 - typedef unsigned int speed_t; 9 7 typedef unsigned int tcflag_t; 10 8 11 9 /* ··· 51 53 }; 52 54 53 55 /* c_cc characters */ 54 - #define VEOF 0 55 - #define VEOL 1 56 - #define VEOL2 2 57 - #define VERASE 3 58 - #define VWERASE 4 59 - #define VKILL 5 60 - #define VREPRINT 6 61 - #define VSWTC 7 62 - #define VINTR 8 63 - #define VQUIT 9 64 - #define VSUSP 10 65 - #define VSTART 12 66 - #define VSTOP 13 67 - #define VLNEXT 14 68 - #define VDISCARD 15 69 - #define VMIN 16 70 - #define VTIME 17 56 + #define VEOF 0 57 + #define VEOL 1 58 + #define VEOL2 2 59 + #define VERASE 3 60 + #define VWERASE 4 61 + #define VKILL 5 62 + #define VREPRINT 6 63 + #define VSWTC 7 64 + #define VINTR 8 65 + #define VQUIT 9 66 + #define VSUSP 10 67 + #define VSTART 12 68 + #define VSTOP 13 69 + #define VLNEXT 14 70 + #define VDISCARD 15 71 + #define VMIN 16 72 + #define VTIME 17 71 73 72 74 /* c_iflag bits */ 73 - #define IGNBRK 0000001 74 - #define BRKINT 0000002 75 - #define IGNPAR 0000004 76 - #define PARMRK 0000010 77 - #define INPCK 0000020 78 - #define ISTRIP 0000040 79 - #define INLCR 0000100 80 - #define IGNCR 0000200 81 - #define ICRNL 0000400 82 - #define IXON 0001000 83 - #define IXOFF 0002000 84 - #define IXANY 0004000 85 - #define IUCLC 0010000 86 - #define IMAXBEL 0020000 87 - #define IUTF8 0040000 75 + #define IXON 0x0200 76 + #define IXOFF 0x0400 77 + #define IUCLC 0x1000 78 + #define IMAXBEL 0x2000 79 + #define IUTF8 0x4000 88 80 89 81 /* c_oflag bits */ 90 - #define OPOST 0000001 91 - #define ONLCR 0000002 92 - #define OLCUC 0000004 93 - 94 - #define OCRNL 0000010 95 - #define ONOCR 0000020 96 - #define ONLRET 0000040 97 - 98 - #define OFILL 00000100 99 - #define OFDEL 00000200 100 - #define NLDLY 00001400 101 - #define NL0 00000000 102 - #define NL1 00000400 103 - #define NL2 00001000 104 - #define NL3 00001400 105 - #define TABDLY 00006000 106 - #define TAB0 00000000 107 - #define TAB1 00002000 108 - #define TAB2 00004000 109 - #define TAB3 00006000 110 - #define CRDLY 00030000 111 - #define CR0 00000000 112 - #define CR1 00010000 113 - #define CR2 00020000 114 - #define CR3 00030000 115 - #define FFDLY 00040000 116 - #define FF0 00000000 117 - #define FF1 00040000 118 - #define BSDLY 00100000 119 - #define BS0 00000000 120 - #define BS1 00100000 121 - #define VTDLY 00200000 122 - #define VT0 00000000 123 - #define VT1 00200000 82 + #define ONLCR 0x00002 83 + #define OLCUC 0x00004 84 + #define NLDLY 0x00300 85 + #define NL0 0x00000 86 + #define NL1 0x00100 87 + #define NL2 0x00200 88 + #define NL3 0x00300 89 + #define TABDLY 0x00c00 90 + #define TAB0 0x00000 91 + #define TAB1 0x00400 92 + #define TAB2 0x00800 93 + #define TAB3 0x00c00 94 + #define CRDLY 0x03000 95 + #define CR0 0x00000 96 + #define CR1 0x01000 97 + #define CR2 0x02000 98 + #define CR3 0x03000 99 + #define FFDLY 0x04000 100 + #define FF0 0x00000 101 + #define FF1 0x04000 102 + #define BSDLY 0x08000 103 + #define BS0 0x00000 104 + #define BS1 0x08000 105 + #define VTDLY 0x10000 106 + #define VT0 0x00000 107 + #define VT1 0x10000 124 108 /* 125 109 * Should be equivalent to TAB3, see description of TAB3 in 126 110 * POSIX.1-2008, Ch. 11.2.3 "Output Modes" ··· 110 130 #define XTABS TAB3 111 131 112 132 /* c_cflag bit meaning */ 113 - #define CBAUD 0000037 114 - #define B0 0000000 /* hang up */ 115 - #define B50 0000001 116 - #define B75 0000002 117 - #define B110 0000003 118 - #define B134 0000004 119 - #define B150 0000005 120 - #define B200 0000006 121 - #define B300 0000007 122 - #define B600 0000010 123 - #define B1200 0000011 124 - #define B1800 0000012 125 - #define B2400 0000013 126 - #define B4800 0000014 127 - #define B9600 0000015 128 - #define B19200 0000016 129 - #define B38400 0000017 130 - #define EXTA B19200 131 - #define EXTB B38400 132 - #define CBAUDEX 0000000 133 - #define B57600 00020 134 - #define B115200 00021 135 - #define B230400 00022 136 - #define B460800 00023 137 - #define B500000 00024 138 - #define B576000 00025 139 - #define B921600 00026 140 - #define B1000000 00027 141 - #define B1152000 00030 142 - #define B1500000 00031 143 - #define B2000000 00032 144 - #define B2500000 00033 145 - #define B3000000 00034 146 - #define B3500000 00035 147 - #define B4000000 00036 148 - #define BOTHER 00037 149 - 150 - #define CSIZE 00001400 151 - #define CS5 00000000 152 - #define CS6 00000400 153 - #define CS7 00001000 154 - #define CS8 00001400 155 - 156 - #define CSTOPB 00002000 157 - #define CREAD 00004000 158 - #define PARENB 00010000 159 - #define PARODD 00020000 160 - #define HUPCL 00040000 161 - 162 - #define CLOCAL 00100000 163 - #define CMSPAR 010000000000 /* mark or space (stick) parity */ 164 - #define CRTSCTS 020000000000 /* flow control */ 165 - 166 - #define CIBAUD 07600000 167 - #define IBSHIFT 16 133 + #define CBAUD 0x0000001f 134 + #define CBAUDEX 0x00000000 135 + #define BOTHER 0x0000001f 136 + #define B57600 0x00000010 137 + #define B115200 0x00000011 138 + #define B230400 0x00000012 139 + #define B460800 0x00000013 140 + #define B500000 0x00000014 141 + #define B576000 0x00000015 142 + #define B921600 0x00000016 143 + #define B1000000 0x00000017 144 + #define B1152000 0x00000018 145 + #define B1500000 0x00000019 146 + #define B2000000 0x0000001a 147 + #define B2500000 0x0000001b 148 + #define B3000000 0x0000001c 149 + #define B3500000 0x0000001d 150 + #define B4000000 0x0000001e 151 + #define CSIZE 0x00000300 152 + #define CS5 0x00000000 153 + #define CS6 0x00000100 154 + #define CS7 0x00000200 155 + #define CS8 0x00000300 156 + #define CSTOPB 0x00000400 157 + #define CREAD 0x00000800 158 + #define PARENB 0x00001000 159 + #define PARODD 0x00002000 160 + #define HUPCL 0x00004000 161 + #define CLOCAL 0x00008000 162 + #define CIBAUD 0x001f0000 168 163 169 164 /* c_lflag bits */ 170 165 #define ISIG 0x00000080 ··· 158 203 #define PENDIN 0x20000000 159 204 #define IEXTEN 0x00000400 160 205 #define EXTPROC 0x10000000 161 - 162 - /* Values for the ACTION argument to `tcflow'. */ 163 - #define TCOOFF 0 164 - #define TCOON 1 165 - #define TCIOFF 2 166 - #define TCION 3 167 - 168 - /* Values for the QUEUE_SELECTOR argument to `tcflush'. */ 169 - #define TCIFLUSH 0 170 - #define TCOFLUSH 1 171 - #define TCIOFLUSH 2 172 206 173 207 /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */ 174 208 #define TCSANOW 0
+99 -150
arch/mips/include/uapi/asm/termbits.h
··· 11 11 #ifndef _ASM_TERMBITS_H 12 12 #define _ASM_TERMBITS_H 13 13 14 - #include <linux/posix_types.h> 14 + #include <asm-generic/termbits-common.h> 15 15 16 - typedef unsigned char cc_t; 17 - typedef unsigned int speed_t; 18 - typedef unsigned int tcflag_t; 16 + typedef unsigned int tcflag_t; 19 17 20 18 /* 21 19 * The ABI says nothing about NCC but seems to use NCCS as ··· 52 54 }; 53 55 54 56 /* c_cc characters */ 55 - #define VINTR 0 /* Interrupt character [ISIG]. */ 56 - #define VQUIT 1 /* Quit character [ISIG]. */ 57 - #define VERASE 2 /* Erase character [ICANON]. */ 58 - #define VKILL 3 /* Kill-line character [ICANON]. */ 59 - #define VMIN 4 /* Minimum number of bytes read at once [!ICANON]. */ 60 - #define VTIME 5 /* Time-out value (tenths of a second) [!ICANON]. */ 61 - #define VEOL2 6 /* Second EOL character [ICANON]. */ 57 + #define VINTR 0 /* Interrupt character [ISIG] */ 58 + #define VQUIT 1 /* Quit character [ISIG] */ 59 + #define VERASE 2 /* Erase character [ICANON] */ 60 + #define VKILL 3 /* Kill-line character [ICANON] */ 61 + #define VMIN 4 /* Minimum number of bytes read at once [!ICANON] */ 62 + #define VTIME 5 /* Time-out value (tenths of a second) [!ICANON] */ 63 + #define VEOL2 6 /* Second EOL character [ICANON] */ 62 64 #define VSWTC 7 /* ??? */ 63 65 #define VSWTCH VSWTC 64 - #define VSTART 8 /* Start (X-ON) character [IXON, IXOFF]. */ 65 - #define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF]. */ 66 - #define VSUSP 10 /* Suspend character [ISIG]. */ 66 + #define VSTART 8 /* Start (X-ON) character [IXON, IXOFF] */ 67 + #define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF] */ 68 + #define VSUSP 10 /* Suspend character [ISIG] */ 67 69 #if 0 68 70 /* 69 71 * VDSUSP is not supported 70 72 */ 71 - #define VDSUSP 11 /* Delayed suspend character [ISIG]. */ 73 + #define VDSUSP 11 /* Delayed suspend character [ISIG] */ 72 74 #endif 73 - #define VREPRINT 12 /* Reprint-line character [ICANON]. */ 74 - #define VDISCARD 13 /* Discard character [IEXTEN]. */ 75 - #define VWERASE 14 /* Word-erase character [ICANON]. */ 76 - #define VLNEXT 15 /* Literal-next character [IEXTEN]. */ 77 - #define VEOF 16 /* End-of-file character [ICANON]. */ 78 - #define VEOL 17 /* End-of-line character [ICANON]. */ 75 + #define VREPRINT 12 /* Reprint-line character [ICANON] */ 76 + #define VDISCARD 13 /* Discard character [IEXTEN] */ 77 + #define VWERASE 14 /* Word-erase character [ICANON] */ 78 + #define VLNEXT 15 /* Literal-next character [IEXTEN] */ 79 + #define VEOF 16 /* End-of-file character [ICANON] */ 80 + #define VEOL 17 /* End-of-line character [ICANON] */ 79 81 80 82 /* c_iflag bits */ 81 - #define IGNBRK 0000001 /* Ignore break condition. */ 82 - #define BRKINT 0000002 /* Signal interrupt on break. */ 83 - #define IGNPAR 0000004 /* Ignore characters with parity errors. */ 84 - #define PARMRK 0000010 /* Mark parity and framing errors. */ 85 - #define INPCK 0000020 /* Enable input parity check. */ 86 - #define ISTRIP 0000040 /* Strip 8th bit off characters. */ 87 - #define INLCR 0000100 /* Map NL to CR on input. */ 88 - #define IGNCR 0000200 /* Ignore CR. */ 89 - #define ICRNL 0000400 /* Map CR to NL on input. */ 90 - #define IUCLC 0001000 /* Map upper case to lower case on input. */ 91 - #define IXON 0002000 /* Enable start/stop output control. */ 92 - #define IXANY 0004000 /* Any character will restart after stop. */ 93 - #define IXOFF 0010000 /* Enable start/stop input control. */ 94 - #define IMAXBEL 0020000 /* Ring bell when input queue is full. */ 95 - #define IUTF8 0040000 /* Input is UTF-8 */ 83 + #define IUCLC 0x0200 /* Map upper case to lower case on input */ 84 + #define IXON 0x0400 /* Enable start/stop output control */ 85 + #define IXOFF 0x1000 /* Enable start/stop input control */ 86 + #define IMAXBEL 0x2000 /* Ring bell when input queue is full */ 87 + #define IUTF8 0x4000 /* Input is UTF-8 */ 96 88 97 89 /* c_oflag bits */ 98 - #define OPOST 0000001 /* Perform output processing. */ 99 - #define OLCUC 0000002 /* Map lower case to upper case on output. */ 100 - #define ONLCR 0000004 /* Map NL to CR-NL on output. */ 101 - #define OCRNL 0000010 102 - #define ONOCR 0000020 103 - #define ONLRET 0000040 104 - #define OFILL 0000100 105 - #define OFDEL 0000200 106 - #define NLDLY 0000400 107 - #define NL0 0000000 108 - #define NL1 0000400 109 - #define CRDLY 0003000 110 - #define CR0 0000000 111 - #define CR1 0001000 112 - #define CR2 0002000 113 - #define CR3 0003000 114 - #define TABDLY 0014000 115 - #define TAB0 0000000 116 - #define TAB1 0004000 117 - #define TAB2 0010000 118 - #define TAB3 0014000 119 - #define XTABS 0014000 120 - #define BSDLY 0020000 121 - #define BS0 0000000 122 - #define BS1 0020000 123 - #define VTDLY 0040000 124 - #define VT0 0000000 125 - #define VT1 0040000 126 - #define FFDLY 0100000 127 - #define FF0 0000000 128 - #define FF1 0100000 90 + #define OLCUC 0x00002 /* Map lower case to upper case on output */ 91 + #define ONLCR 0x00004 /* Map NL to CR-NL on output */ 92 + #define NLDLY 0x00100 93 + #define NL0 0x00000 94 + #define NL1 0x00100 95 + #define CRDLY 0x00600 96 + #define CR0 0x00000 97 + #define CR1 0x00200 98 + #define CR2 0x00400 99 + #define CR3 0x00600 100 + #define TABDLY 0x01800 101 + #define TAB0 0x00000 102 + #define TAB1 0x00800 103 + #define TAB2 0x01000 104 + #define TAB3 0x01800 105 + #define XTABS 0x01800 106 + #define BSDLY 0x02000 107 + #define BS0 0x00000 108 + #define BS1 0x02000 109 + #define VTDLY 0x04000 110 + #define VT0 0x00000 111 + #define VT1 0x04000 112 + #define FFDLY 0x08000 113 + #define FF0 0x00000 114 + #define FF1 0x08000 129 115 /* 130 116 #define PAGEOUT ??? 131 117 #define WRAP ??? 132 118 */ 133 119 134 120 /* c_cflag bit meaning */ 135 - #define CBAUD 0010017 136 - #define B0 0000000 /* hang up */ 137 - #define B50 0000001 138 - #define B75 0000002 139 - #define B110 0000003 140 - #define B134 0000004 141 - #define B150 0000005 142 - #define B200 0000006 143 - #define B300 0000007 144 - #define B600 0000010 145 - #define B1200 0000011 146 - #define B1800 0000012 147 - #define B2400 0000013 148 - #define B4800 0000014 149 - #define B9600 0000015 150 - #define B19200 0000016 151 - #define B38400 0000017 152 - #define EXTA B19200 153 - #define EXTB B38400 154 - #define CSIZE 0000060 /* Number of bits per byte (mask). */ 155 - #define CS5 0000000 /* 5 bits per byte. */ 156 - #define CS6 0000020 /* 6 bits per byte. */ 157 - #define CS7 0000040 /* 7 bits per byte. */ 158 - #define CS8 0000060 /* 8 bits per byte. */ 159 - #define CSTOPB 0000100 /* Two stop bits instead of one. */ 160 - #define CREAD 0000200 /* Enable receiver. */ 161 - #define PARENB 0000400 /* Parity enable. */ 162 - #define PARODD 0001000 /* Odd parity instead of even. */ 163 - #define HUPCL 0002000 /* Hang up on last close. */ 164 - #define CLOCAL 0004000 /* Ignore modem status lines. */ 165 - #define CBAUDEX 0010000 166 - #define BOTHER 0010000 167 - #define B57600 0010001 168 - #define B115200 0010002 169 - #define B230400 0010003 170 - #define B460800 0010004 171 - #define B500000 0010005 172 - #define B576000 0010006 173 - #define B921600 0010007 174 - #define B1000000 0010010 175 - #define B1152000 0010011 176 - #define B1500000 0010012 177 - #define B2000000 0010013 178 - #define B2500000 0010014 179 - #define B3000000 0010015 180 - #define B3500000 0010016 181 - #define B4000000 0010017 182 - #define CIBAUD 002003600000 /* input baud rate */ 183 - #define CMSPAR 010000000000 /* mark or space (stick) parity */ 184 - #define CRTSCTS 020000000000 /* flow control */ 185 - 186 - #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ 121 + #define CBAUD 0x0000100f 122 + #define CSIZE 0x00000030 /* Number of bits per byte (mask) */ 123 + #define CS5 0x00000000 /* 5 bits per byte */ 124 + #define CS6 0x00000010 /* 6 bits per byte */ 125 + #define CS7 0x00000020 /* 7 bits per byte */ 126 + #define CS8 0x00000030 /* 8 bits per byte */ 127 + #define CSTOPB 0x00000040 /* Two stop bits instead of one */ 128 + #define CREAD 0x00000080 /* Enable receiver */ 129 + #define PARENB 0x00000100 /* Parity enable */ 130 + #define PARODD 0x00000200 /* Odd parity instead of even */ 131 + #define HUPCL 0x00000400 /* Hang up on last close */ 132 + #define CLOCAL 0x00000800 /* Ignore modem status lines */ 133 + #define CBAUDEX 0x00001000 134 + #define BOTHER 0x00001000 135 + #define B57600 0x00001001 136 + #define B115200 0x00001002 137 + #define B230400 0x00001003 138 + #define B460800 0x00001004 139 + #define B500000 0x00001005 140 + #define B576000 0x00001006 141 + #define B921600 0x00001007 142 + #define B1000000 0x00001008 143 + #define B1152000 0x00001009 144 + #define B1500000 0x0000100a 145 + #define B2000000 0x0000100b 146 + #define B2500000 0x0000100c 147 + #define B3000000 0x0000100d 148 + #define B3500000 0x0000100e 149 + #define B4000000 0x0000100f 150 + #define CIBAUD 0x100f0000 /* input baud rate */ 187 151 188 152 /* c_lflag bits */ 189 - #define ISIG 0000001 /* Enable signals. */ 190 - #define ICANON 0000002 /* Do erase and kill processing. */ 191 - #define XCASE 0000004 192 - #define ECHO 0000010 /* Enable echo. */ 193 - #define ECHOE 0000020 /* Visual erase for ERASE. */ 194 - #define ECHOK 0000040 /* Echo NL after KILL. */ 195 - #define ECHONL 0000100 /* Echo NL even if ECHO is off. */ 196 - #define NOFLSH 0000200 /* Disable flush after interrupt. */ 197 - #define IEXTEN 0000400 /* Enable DISCARD and LNEXT. */ 198 - #define ECHOCTL 0001000 /* Echo control characters as ^X. */ 199 - #define ECHOPRT 0002000 /* Hardcopy visual erase. */ 200 - #define ECHOKE 0004000 /* Visual erase for KILL. */ 201 - #define FLUSHO 0020000 202 - #define PENDIN 0040000 /* Retype pending input (state). */ 203 - #define TOSTOP 0100000 /* Send SIGTTOU for background output. */ 204 - #define ITOSTOP TOSTOP 205 - #define EXTPROC 0200000 /* External processing on pty */ 153 + #define ISIG 0x00001 /* Enable signals */ 154 + #define ICANON 0x00002 /* Do erase and kill processing */ 155 + #define XCASE 0x00004 156 + #define ECHO 0x00008 /* Enable echo */ 157 + #define ECHOE 0x00010 /* Visual erase for ERASE */ 158 + #define ECHOK 0x00020 /* Echo NL after KILL */ 159 + #define ECHONL 0x00040 /* Echo NL even if ECHO is off */ 160 + #define NOFLSH 0x00080 /* Disable flush after interrupt */ 161 + #define IEXTEN 0x00100 /* Enable DISCARD and LNEXT */ 162 + #define ECHOCTL 0x00200 /* Echo control characters as ^X */ 163 + #define ECHOPRT 0x00400 /* Hardcopy visual erase */ 164 + #define ECHOKE 0x00800 /* Visual erase for KILL */ 165 + #define FLUSHO 0x02000 166 + #define PENDIN 0x04000 /* Retype pending input (state) */ 167 + #define TOSTOP 0x08000 /* Send SIGTTOU for background output */ 168 + #define ITOSTOP TOSTOP 169 + #define EXTPROC 0x10000 /* External processing on pty */ 206 170 207 171 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ 208 172 #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 209 173 210 - /* tcflow() and TCXONC use these */ 211 - #define TCOOFF 0 /* Suspend output. */ 212 - #define TCOON 1 /* Restart suspended output. */ 213 - #define TCIOFF 2 /* Send a STOP character. */ 214 - #define TCION 3 /* Send a START character. */ 215 - 216 - /* tcflush() and TCFLSH use these */ 217 - #define TCIFLUSH 0 /* Discard data received but not yet read. */ 218 - #define TCOFLUSH 1 /* Discard data written but not yet sent. */ 219 - #define TCIOFLUSH 2 /* Discard all pending data. */ 220 - 221 174 /* tcsetattr uses these */ 222 - #define TCSANOW TCSETS /* Change immediately. */ 223 - #define TCSADRAIN TCSETSW /* Change when pending output is written. */ 224 - #define TCSAFLUSH TCSETSF /* Flush pending input before changing. */ 175 + #define TCSANOW TCSETS /* Change immediately */ 176 + #define TCSADRAIN TCSETSW /* Change when pending output is written */ 177 + #define TCSAFLUSH TCSETSF /* Flush pending input before changing */ 225 178 226 179 #endif /* _ASM_TERMBITS_H */
+94 -147
arch/parisc/include/uapi/asm/termbits.h
··· 2 2 #ifndef __ARCH_PARISC_TERMBITS_H__ 3 3 #define __ARCH_PARISC_TERMBITS_H__ 4 4 5 - #include <linux/posix_types.h> 5 + #include <asm-generic/termbits-common.h> 6 6 7 - typedef unsigned char cc_t; 8 - typedef unsigned int speed_t; 9 7 typedef unsigned int tcflag_t; 10 8 11 9 #define NCCS 19 ··· 39 41 }; 40 42 41 43 /* c_cc characters */ 42 - #define VINTR 0 43 - #define VQUIT 1 44 - #define VERASE 2 45 - #define VKILL 3 46 - #define VEOF 4 47 - #define VTIME 5 48 - #define VMIN 6 49 - #define VSWTC 7 50 - #define VSTART 8 51 - #define VSTOP 9 52 - #define VSUSP 10 53 - #define VEOL 11 54 - #define VREPRINT 12 55 - #define VDISCARD 13 56 - #define VWERASE 14 57 - #define VLNEXT 15 58 - #define VEOL2 16 59 - 44 + #define VINTR 0 45 + #define VQUIT 1 46 + #define VERASE 2 47 + #define VKILL 3 48 + #define VEOF 4 49 + #define VTIME 5 50 + #define VMIN 6 51 + #define VSWTC 7 52 + #define VSTART 8 53 + #define VSTOP 9 54 + #define VSUSP 10 55 + #define VEOL 11 56 + #define VREPRINT 12 57 + #define VDISCARD 13 58 + #define VWERASE 14 59 + #define VLNEXT 15 60 + #define VEOL2 16 60 61 61 62 /* c_iflag bits */ 62 - #define IGNBRK 0000001 63 - #define BRKINT 0000002 64 - #define IGNPAR 0000004 65 - #define PARMRK 0000010 66 - #define INPCK 0000020 67 - #define ISTRIP 0000040 68 - #define INLCR 0000100 69 - #define IGNCR 0000200 70 - #define ICRNL 0000400 71 - #define IUCLC 0001000 72 - #define IXON 0002000 73 - #define IXANY 0004000 74 - #define IXOFF 0010000 75 - #define IMAXBEL 0040000 76 - #define IUTF8 0100000 63 + #define IUCLC 0x0200 64 + #define IXON 0x0400 65 + #define IXOFF 0x1000 66 + #define IMAXBEL 0x4000 67 + #define IUTF8 0x8000 77 68 78 69 /* c_oflag bits */ 79 - #define OPOST 0000001 80 - #define OLCUC 0000002 81 - #define ONLCR 0000004 82 - #define OCRNL 0000010 83 - #define ONOCR 0000020 84 - #define ONLRET 0000040 85 - #define OFILL 0000100 86 - #define OFDEL 0000200 87 - #define NLDLY 0000400 88 - #define NL0 0000000 89 - #define NL1 0000400 90 - #define CRDLY 0003000 91 - #define CR0 0000000 92 - #define CR1 0001000 93 - #define CR2 0002000 94 - #define CR3 0003000 95 - #define TABDLY 0014000 96 - #define TAB0 0000000 97 - #define TAB1 0004000 98 - #define TAB2 0010000 99 - #define TAB3 0014000 100 - #define XTABS 0014000 101 - #define BSDLY 0020000 102 - #define BS0 0000000 103 - #define BS1 0020000 104 - #define VTDLY 0040000 105 - #define VT0 0000000 106 - #define VT1 0040000 107 - #define FFDLY 0100000 108 - #define FF0 0000000 109 - #define FF1 0100000 70 + #define OLCUC 0x00002 71 + #define ONLCR 0x00004 72 + #define NLDLY 0x00100 73 + #define NL0 0x00000 74 + #define NL1 0x00100 75 + #define CRDLY 0x00600 76 + #define CR0 0x00000 77 + #define CR1 0x00200 78 + #define CR2 0x00400 79 + #define CR3 0x00600 80 + #define TABDLY 0x01800 81 + #define TAB0 0x00000 82 + #define TAB1 0x00800 83 + #define TAB2 0x01000 84 + #define TAB3 0x01800 85 + #define XTABS 0x01800 86 + #define BSDLY 0x02000 87 + #define BS0 0x00000 88 + #define BS1 0x02000 89 + #define VTDLY 0x04000 90 + #define VT0 0x00000 91 + #define VT1 0x04000 92 + #define FFDLY 0x08000 93 + #define FF0 0x00000 94 + #define FF1 0x08000 110 95 111 96 /* c_cflag bit meaning */ 112 - #define CBAUD 0010017 113 - #define B0 0000000 /* hang up */ 114 - #define B50 0000001 115 - #define B75 0000002 116 - #define B110 0000003 117 - #define B134 0000004 118 - #define B150 0000005 119 - #define B200 0000006 120 - #define B300 0000007 121 - #define B600 0000010 122 - #define B1200 0000011 123 - #define B1800 0000012 124 - #define B2400 0000013 125 - #define B4800 0000014 126 - #define B9600 0000015 127 - #define B19200 0000016 128 - #define B38400 0000017 129 - #define EXTA B19200 130 - #define EXTB B38400 131 - #define CSIZE 0000060 132 - #define CS5 0000000 133 - #define CS6 0000020 134 - #define CS7 0000040 135 - #define CS8 0000060 136 - #define CSTOPB 0000100 137 - #define CREAD 0000200 138 - #define PARENB 0000400 139 - #define PARODD 0001000 140 - #define HUPCL 0002000 141 - #define CLOCAL 0004000 142 - #define CBAUDEX 0010000 143 - #define BOTHER 0010000 144 - #define B57600 0010001 145 - #define B115200 0010002 146 - #define B230400 0010003 147 - #define B460800 0010004 148 - #define B500000 0010005 149 - #define B576000 0010006 150 - #define B921600 0010007 151 - #define B1000000 0010010 152 - #define B1152000 0010011 153 - #define B1500000 0010012 154 - #define B2000000 0010013 155 - #define B2500000 0010014 156 - #define B3000000 0010015 157 - #define B3500000 0010016 158 - #define B4000000 0010017 159 - #define CIBAUD 002003600000 /* input baud rate */ 160 - #define CMSPAR 010000000000 /* mark or space (stick) parity */ 161 - #define CRTSCTS 020000000000 /* flow control */ 162 - 163 - #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ 164 - 97 + #define CBAUD 0x0000100f 98 + #define CSIZE 0x00000030 99 + #define CS5 0x00000000 100 + #define CS6 0x00000010 101 + #define CS7 0x00000020 102 + #define CS8 0x00000030 103 + #define CSTOPB 0x00000040 104 + #define CREAD 0x00000080 105 + #define PARENB 0x00000100 106 + #define PARODD 0x00000200 107 + #define HUPCL 0x00000400 108 + #define CLOCAL 0x00000800 109 + #define CBAUDEX 0x00001000 110 + #define BOTHER 0x00001000 111 + #define B57600 0x00001001 112 + #define B115200 0x00001002 113 + #define B230400 0x00001003 114 + #define B460800 0x00001004 115 + #define B500000 0x00001005 116 + #define B576000 0x00001006 117 + #define B921600 0x00001007 118 + #define B1000000 0x00001008 119 + #define B1152000 0x00001009 120 + #define B1500000 0x0000100a 121 + #define B2000000 0x0000100b 122 + #define B2500000 0x0000100c 123 + #define B3000000 0x0000100d 124 + #define B3500000 0x0000100e 125 + #define B4000000 0x0000100f 126 + #define CIBAUD 0x100f0000 /* input baud rate */ 165 127 166 128 /* c_lflag bits */ 167 - #define ISIG 0000001 168 - #define ICANON 0000002 169 - #define XCASE 0000004 170 - #define ECHO 0000010 171 - #define ECHOE 0000020 172 - #define ECHOK 0000040 173 - #define ECHONL 0000100 174 - #define NOFLSH 0000200 175 - #define TOSTOP 0000400 176 - #define ECHOCTL 0001000 177 - #define ECHOPRT 0002000 178 - #define ECHOKE 0004000 179 - #define FLUSHO 0010000 180 - #define PENDIN 0040000 181 - #define IEXTEN 0100000 182 - #define EXTPROC 0200000 183 - 184 - /* tcflow() and TCXONC use these */ 185 - #define TCOOFF 0 186 - #define TCOON 1 187 - #define TCIOFF 2 188 - #define TCION 3 189 - 190 - /* tcflush() and TCFLSH use these */ 191 - #define TCIFLUSH 0 192 - #define TCOFLUSH 1 193 - #define TCIOFLUSH 2 129 + #define ISIG 0x00001 130 + #define ICANON 0x00002 131 + #define XCASE 0x00004 132 + #define ECHO 0x00008 133 + #define ECHOE 0x00010 134 + #define ECHOK 0x00020 135 + #define ECHONL 0x00040 136 + #define NOFLSH 0x00080 137 + #define TOSTOP 0x00100 138 + #define ECHOCTL 0x00200 139 + #define ECHOPRT 0x00400 140 + #define ECHOKE 0x00800 141 + #define FLUSHO 0x01000 142 + #define PENDIN 0x04000 143 + #define IEXTEN 0x08000 144 + #define EXTPROC 0x10000 194 145 195 146 /* tcsetattr uses these */ 196 147 #define TCSANOW 0
+64 -118
arch/powerpc/include/uapi/asm/termbits.h
··· 9 9 * 2 of the License, or (at your option) any later version. 10 10 */ 11 11 12 - typedef unsigned char cc_t; 13 - typedef unsigned int speed_t; 12 + #include <asm-generic/termbits-common.h> 13 + 14 14 typedef unsigned int tcflag_t; 15 15 16 16 /* ··· 64 64 #define VDISCARD 16 65 65 66 66 /* c_iflag bits */ 67 - #define IGNBRK 0000001 68 - #define BRKINT 0000002 69 - #define IGNPAR 0000004 70 - #define PARMRK 0000010 71 - #define INPCK 0000020 72 - #define ISTRIP 0000040 73 - #define INLCR 0000100 74 - #define IGNCR 0000200 75 - #define ICRNL 0000400 76 - #define IXON 0001000 77 - #define IXOFF 0002000 78 - #define IXANY 0004000 79 - #define IUCLC 0010000 80 - #define IMAXBEL 0020000 81 - #define IUTF8 0040000 67 + #define IXON 0x0200 68 + #define IXOFF 0x0400 69 + #define IUCLC 0x1000 70 + #define IMAXBEL 0x2000 71 + #define IUTF8 0x4000 82 72 83 73 /* c_oflag bits */ 84 - #define OPOST 0000001 85 - #define ONLCR 0000002 86 - #define OLCUC 0000004 87 - 88 - #define OCRNL 0000010 89 - #define ONOCR 0000020 90 - #define ONLRET 0000040 91 - 92 - #define OFILL 00000100 93 - #define OFDEL 00000200 94 - #define NLDLY 00001400 95 - #define NL0 00000000 96 - #define NL1 00000400 97 - #define NL2 00001000 98 - #define NL3 00001400 99 - #define TABDLY 00006000 100 - #define TAB0 00000000 101 - #define TAB1 00002000 102 - #define TAB2 00004000 103 - #define TAB3 00006000 104 - #define XTABS 00006000 /* required by POSIX to == TAB3 */ 105 - #define CRDLY 00030000 106 - #define CR0 00000000 107 - #define CR1 00010000 108 - #define CR2 00020000 109 - #define CR3 00030000 110 - #define FFDLY 00040000 111 - #define FF0 00000000 112 - #define FF1 00040000 113 - #define BSDLY 00100000 114 - #define BS0 00000000 115 - #define BS1 00100000 116 - #define VTDLY 00200000 117 - #define VT0 00000000 118 - #define VT1 00200000 74 + #define ONLCR 0x00002 75 + #define OLCUC 0x00004 76 + #define NLDLY 0x00300 77 + #define NL0 0x00000 78 + #define NL1 0x00100 79 + #define NL2 0x00200 80 + #define NL3 0x00300 81 + #define TABDLY 0x00c00 82 + #define TAB0 0x00000 83 + #define TAB1 0x00400 84 + #define TAB2 0x00800 85 + #define TAB3 0x00c00 86 + #define XTABS 0x00c00 /* required by POSIX to == TAB3 */ 87 + #define CRDLY 0x03000 88 + #define CR0 0x00000 89 + #define CR1 0x01000 90 + #define CR2 0x02000 91 + #define CR3 0x03000 92 + #define FFDLY 0x04000 93 + #define FF0 0x00000 94 + #define FF1 0x04000 95 + #define BSDLY 0x08000 96 + #define BS0 0x00000 97 + #define BS1 0x08000 98 + #define VTDLY 0x10000 99 + #define VT0 0x00000 100 + #define VT1 0x10000 119 101 120 102 /* c_cflag bit meaning */ 121 - #define CBAUD 0000377 122 - #define B0 0000000 /* hang up */ 123 - #define B50 0000001 124 - #define B75 0000002 125 - #define B110 0000003 126 - #define B134 0000004 127 - #define B150 0000005 128 - #define B200 0000006 129 - #define B300 0000007 130 - #define B600 0000010 131 - #define B1200 0000011 132 - #define B1800 0000012 133 - #define B2400 0000013 134 - #define B4800 0000014 135 - #define B9600 0000015 136 - #define B19200 0000016 137 - #define B38400 0000017 138 - #define EXTA B19200 139 - #define EXTB B38400 140 - #define CBAUDEX 0000000 141 - #define B57600 00020 142 - #define B115200 00021 143 - #define B230400 00022 144 - #define B460800 00023 145 - #define B500000 00024 146 - #define B576000 00025 147 - #define B921600 00026 148 - #define B1000000 00027 149 - #define B1152000 00030 150 - #define B1500000 00031 151 - #define B2000000 00032 152 - #define B2500000 00033 153 - #define B3000000 00034 154 - #define B3500000 00035 155 - #define B4000000 00036 156 - #define BOTHER 00037 157 - 158 - #define CIBAUD 077600000 159 - #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ 160 - 161 - #define CSIZE 00001400 162 - #define CS5 00000000 163 - #define CS6 00000400 164 - #define CS7 00001000 165 - #define CS8 00001400 166 - 167 - #define CSTOPB 00002000 168 - #define CREAD 00004000 169 - #define PARENB 00010000 170 - #define PARODD 00020000 171 - #define HUPCL 00040000 172 - 173 - #define CLOCAL 00100000 174 - #define CMSPAR 010000000000 /* mark or space (stick) parity */ 175 - #define CRTSCTS 020000000000 /* flow control */ 103 + #define CBAUD 0x000000ff 104 + #define CBAUDEX 0x00000000 105 + #define BOTHER 0x0000001f 106 + #define B57600 0x00000010 107 + #define B115200 0x00000011 108 + #define B230400 0x00000012 109 + #define B460800 0x00000013 110 + #define B500000 0x00000014 111 + #define B576000 0x00000015 112 + #define B921600 0x00000016 113 + #define B1000000 0x00000017 114 + #define B1152000 0x00000018 115 + #define B1500000 0x00000019 116 + #define B2000000 0x0000001a 117 + #define B2500000 0x0000001b 118 + #define B3000000 0x0000001c 119 + #define B3500000 0x0000001d 120 + #define B4000000 0x0000001e 121 + #define CSIZE 0x00000300 122 + #define CS5 0x00000000 123 + #define CS6 0x00000100 124 + #define CS7 0x00000200 125 + #define CS8 0x00000300 126 + #define CSTOPB 0x00000400 127 + #define CREAD 0x00000800 128 + #define PARENB 0x00001000 129 + #define PARODD 0x00002000 130 + #define HUPCL 0x00004000 131 + #define CLOCAL 0x00008000 132 + #define CIBAUD 0x00ff0000 176 133 177 134 /* c_lflag bits */ 178 135 #define ISIG 0x00000080 ··· 148 191 #define PENDIN 0x20000000 149 192 #define IEXTEN 0x00000400 150 193 #define EXTPROC 0x10000000 151 - 152 - /* Values for the ACTION argument to `tcflow'. */ 153 - #define TCOOFF 0 154 - #define TCOON 1 155 - #define TCIOFF 2 156 - #define TCION 3 157 - 158 - /* Values for the QUEUE_SELECTOR argument to `tcflush'. */ 159 - #define TCIFLUSH 0 160 - #define TCOFLUSH 1 161 - #define TCIOFLUSH 2 162 194 163 195 /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */ 164 196 #define TCSANOW 0
+84 -139
arch/sparc/include/uapi/asm/termbits.h
··· 2 2 #ifndef _UAPI_SPARC_TERMBITS_H 3 3 #define _UAPI_SPARC_TERMBITS_H 4 4 5 - #include <linux/posix_types.h> 6 - 7 - typedef unsigned char cc_t; 8 - typedef unsigned int speed_t; 5 + #include <asm-generic/termbits-common.h> 9 6 10 7 #if defined(__sparc__) && defined(__arch64__) 11 - typedef unsigned int tcflag_t; 8 + typedef unsigned int tcflag_t; 12 9 #else 13 - typedef unsigned long tcflag_t; 10 + typedef unsigned long tcflag_t; 14 11 #endif 15 12 16 13 #define NCC 8 ··· 58 61 }; 59 62 60 63 /* c_cc characters */ 61 - #define VINTR 0 62 - #define VQUIT 1 63 - #define VERASE 2 64 - #define VKILL 3 65 - #define VEOF 4 66 - #define VEOL 5 67 - #define VEOL2 6 68 - #define VSWTC 7 69 - #define VSTART 8 70 - #define VSTOP 9 71 - 72 - 64 + #define VINTR 0 65 + #define VQUIT 1 66 + #define VERASE 2 67 + #define VKILL 3 68 + #define VEOF 4 69 + #define VEOL 5 70 + #define VEOL2 6 71 + #define VSWTC 7 72 + #define VSTART 8 73 + #define VSTOP 9 73 74 74 75 #define VSUSP 10 75 - #define VDSUSP 11 /* SunOS POSIX nicety I do believe... */ 76 + #define VDSUSP 11 /* SunOS POSIX nicety I do believe... */ 76 77 #define VREPRINT 12 77 78 #define VDISCARD 13 78 79 #define VWERASE 14 ··· 85 90 #endif 86 91 87 92 /* c_iflag bits */ 88 - #define IGNBRK 0x00000001 89 - #define BRKINT 0x00000002 90 - #define IGNPAR 0x00000004 91 - #define PARMRK 0x00000008 92 - #define INPCK 0x00000010 93 - #define ISTRIP 0x00000020 94 - #define INLCR 0x00000040 95 - #define IGNCR 0x00000080 96 - #define ICRNL 0x00000100 97 - #define IUCLC 0x00000200 98 - #define IXON 0x00000400 99 - #define IXANY 0x00000800 100 - #define IXOFF 0x00001000 101 - #define IMAXBEL 0x00002000 102 - #define IUTF8 0x00004000 93 + #define IUCLC 0x0200 94 + #define IXON 0x0400 95 + #define IXOFF 0x1000 96 + #define IMAXBEL 0x2000 97 + #define IUTF8 0x4000 103 98 104 99 /* c_oflag bits */ 105 - #define OPOST 0x00000001 106 - #define OLCUC 0x00000002 107 - #define ONLCR 0x00000004 108 - #define OCRNL 0x00000008 109 - #define ONOCR 0x00000010 110 - #define ONLRET 0x00000020 111 - #define OFILL 0x00000040 112 - #define OFDEL 0x00000080 113 - #define NLDLY 0x00000100 114 - #define NL0 0x00000000 115 - #define NL1 0x00000100 116 - #define CRDLY 0x00000600 117 - #define CR0 0x00000000 118 - #define CR1 0x00000200 119 - #define CR2 0x00000400 120 - #define CR3 0x00000600 121 - #define TABDLY 0x00001800 122 - #define TAB0 0x00000000 123 - #define TAB1 0x00000800 124 - #define TAB2 0x00001000 125 - #define TAB3 0x00001800 126 - #define XTABS 0x00001800 127 - #define BSDLY 0x00002000 128 - #define BS0 0x00000000 129 - #define BS1 0x00002000 130 - #define VTDLY 0x00004000 131 - #define VT0 0x00000000 132 - #define VT1 0x00004000 133 - #define FFDLY 0x00008000 134 - #define FF0 0x00000000 135 - #define FF1 0x00008000 136 - #define PAGEOUT 0x00010000 /* SUNOS specific */ 137 - #define WRAP 0x00020000 /* SUNOS specific */ 100 + #define OLCUC 0x00002 101 + #define ONLCR 0x00004 102 + #define NLDLY 0x00100 103 + #define NL0 0x00000 104 + #define NL1 0x00100 105 + #define CRDLY 0x00600 106 + #define CR0 0x00000 107 + #define CR1 0x00200 108 + #define CR2 0x00400 109 + #define CR3 0x00600 110 + #define TABDLY 0x01800 111 + #define TAB0 0x00000 112 + #define TAB1 0x00800 113 + #define TAB2 0x01000 114 + #define TAB3 0x01800 115 + #define XTABS 0x01800 116 + #define BSDLY 0x02000 117 + #define BS0 0x00000 118 + #define BS1 0x02000 119 + #define VTDLY 0x04000 120 + #define VT0 0x00000 121 + #define VT1 0x04000 122 + #define FFDLY 0x08000 123 + #define FF0 0x00000 124 + #define FF1 0x08000 125 + #define PAGEOUT 0x10000 /* SUNOS specific */ 126 + #define WRAP 0x20000 /* SUNOS specific */ 138 127 139 128 /* c_cflag bit meaning */ 140 - #define CBAUD 0x0000100f 141 - #define B0 0x00000000 /* hang up */ 142 - #define B50 0x00000001 143 - #define B75 0x00000002 144 - #define B110 0x00000003 145 - #define B134 0x00000004 146 - #define B150 0x00000005 147 - #define B200 0x00000006 148 - #define B300 0x00000007 149 - #define B600 0x00000008 150 - #define B1200 0x00000009 151 - #define B1800 0x0000000a 152 - #define B2400 0x0000000b 153 - #define B4800 0x0000000c 154 - #define B9600 0x0000000d 155 - #define B19200 0x0000000e 156 - #define B38400 0x0000000f 157 - #define EXTA B19200 158 - #define EXTB B38400 159 - #define CSIZE 0x00000030 160 - #define CS5 0x00000000 161 - #define CS6 0x00000010 162 - #define CS7 0x00000020 163 - #define CS8 0x00000030 164 - #define CSTOPB 0x00000040 165 - #define CREAD 0x00000080 166 - #define PARENB 0x00000100 167 - #define PARODD 0x00000200 168 - #define HUPCL 0x00000400 169 - #define CLOCAL 0x00000800 170 - #define CBAUDEX 0x00001000 129 + #define CBAUD 0x0000100f 130 + #define CSIZE 0x00000030 131 + #define CS5 0x00000000 132 + #define CS6 0x00000010 133 + #define CS7 0x00000020 134 + #define CS8 0x00000030 135 + #define CSTOPB 0x00000040 136 + #define CREAD 0x00000080 137 + #define PARENB 0x00000100 138 + #define PARODD 0x00000200 139 + #define HUPCL 0x00000400 140 + #define CLOCAL 0x00000800 141 + #define CBAUDEX 0x00001000 171 142 /* We'll never see these speeds with the Zilogs, but for completeness... */ 172 - #define BOTHER 0x00001000 173 - #define B57600 0x00001001 174 - #define B115200 0x00001002 175 - #define B230400 0x00001003 176 - #define B460800 0x00001004 143 + #define BOTHER 0x00001000 144 + #define B57600 0x00001001 145 + #define B115200 0x00001002 146 + #define B230400 0x00001003 147 + #define B460800 0x00001004 177 148 /* This is what we can do with the Zilogs. */ 178 - #define B76800 0x00001005 149 + #define B76800 0x00001005 179 150 /* This is what we can do with the SAB82532. */ 180 - #define B153600 0x00001006 181 - #define B307200 0x00001007 182 - #define B614400 0x00001008 183 - #define B921600 0x00001009 151 + #define B153600 0x00001006 152 + #define B307200 0x00001007 153 + #define B614400 0x00001008 154 + #define B921600 0x00001009 184 155 /* And these are the rest... */ 185 - #define B500000 0x0000100a 186 - #define B576000 0x0000100b 187 - #define B1000000 0x0000100c 188 - #define B1152000 0x0000100d 189 - #define B1500000 0x0000100e 190 - #define B2000000 0x0000100f 156 + #define B500000 0x0000100a 157 + #define B576000 0x0000100b 158 + #define B1000000 0x0000100c 159 + #define B1152000 0x0000100d 160 + #define B1500000 0x0000100e 161 + #define B2000000 0x0000100f 191 162 /* These have totally bogus values and nobody uses them 192 163 so far. Later on we'd have to use say 0x10000x and 193 164 adjust CBAUD constant and drivers accordingly. 194 - #define B2500000 0x00001010 195 - #define B3000000 0x00001011 196 - #define B3500000 0x00001012 197 - #define B4000000 0x00001013 */ 198 - #define CIBAUD 0x100f0000 /* input baud rate (not used) */ 199 - #define CMSPAR 0x40000000 /* mark or space (stick) parity */ 200 - #define CRTSCTS 0x80000000 /* flow control */ 201 - 202 - #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ 165 + #define B2500000 0x00001010 166 + #define B3000000 0x00001011 167 + #define B3500000 0x00001012 168 + #define B4000000 0x00001013 */ 169 + #define CIBAUD 0x100f0000 /* input baud rate (not used) */ 203 170 204 171 /* c_lflag bits */ 205 172 #define ISIG 0x00000001 ··· 176 219 #define ECHOCTL 0x00000200 177 220 #define ECHOPRT 0x00000400 178 221 #define ECHOKE 0x00000800 179 - #define DEFECHO 0x00001000 /* SUNOS thing, what is it? */ 222 + #define DEFECHO 0x00001000 /* SUNOS thing, what is it? */ 180 223 #define FLUSHO 0x00002000 181 224 #define PENDIN 0x00004000 182 225 #define IEXTEN 0x00008000 ··· 201 244 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ 202 245 #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 203 246 204 - 205 - /* tcflow() and TCXONC use these */ 206 - #define TCOOFF 0 207 - #define TCOON 1 208 - #define TCIOFF 2 209 - #define TCION 3 210 - 211 - /* tcflush() and TCFLSH use these */ 212 - #define TCIFLUSH 0 213 - #define TCOFLUSH 1 214 - #define TCIOFLUSH 2 215 - 216 247 /* tcsetattr uses these */ 217 - #define TCSANOW 0 218 - #define TCSADRAIN 1 219 - #define TCSAFLUSH 2 248 + #define TCSANOW 0 249 + #define TCSADRAIN 1 250 + #define TCSAFLUSH 2 220 251 221 252 #endif /* _UAPI_SPARC_TERMBITS_H */
+2 -1
drivers/char/Kconfig
··· 18 18 The feature is useful to inline user messages with kernel 19 19 messages. 20 20 In order to use this feature, you should output user messages 21 - to /dev/ttyprintk or redirect console to this TTY. 21 + to /dev/ttyprintk or redirect console to this TTY, or boot 22 + the kernel with console=ttyprintk. 22 23 23 24 If unsure, say N. 24 25
+16
drivers/char/ttyprintk.c
··· 11 11 * of the boot process, for example. 12 12 */ 13 13 14 + #include <linux/console.h> 14 15 #include <linux/device.h> 15 16 #include <linux/serial.h> 16 17 #include <linux/tty.h> ··· 164 163 165 164 static struct tty_driver *ttyprintk_driver; 166 165 166 + static struct tty_driver *ttyprintk_console_device(struct console *c, 167 + int *index) 168 + { 169 + *index = 0; 170 + return ttyprintk_driver; 171 + } 172 + 173 + static struct console ttyprintk_console = { 174 + .name = "ttyprintk", 175 + .device = ttyprintk_console_device, 176 + }; 177 + 167 178 static int __init ttyprintk_init(void) 168 179 { 169 180 int ret; ··· 208 195 goto error; 209 196 } 210 197 198 + register_console(&ttyprintk_console); 199 + 211 200 return 0; 212 201 213 202 error: ··· 220 205 221 206 static void __exit ttyprintk_exit(void) 222 207 { 208 + unregister_console(&ttyprintk_console); 223 209 tty_unregister_driver(ttyprintk_driver); 224 210 tty_driver_kref_put(ttyprintk_driver); 225 211 tty_port_destroy(&tpk_port.port);
-2
drivers/tty/amiserial.c
··· 588 588 } 589 589 if (!(cflag & PARODD)) 590 590 cval |= UART_LCR_EPAR; 591 - #ifdef CMSPAR 592 591 if (cflag & CMSPAR) 593 592 cval |= UART_LCR_SPAR; 594 - #endif 595 593 596 594 /* Determine divisor based on baud rate */ 597 595 baud = tty_get_baud_rate(tty);
+2
drivers/tty/goldfish.c
··· 405 405 err_tty_register_device_failed: 406 406 free_irq(irq, qtty); 407 407 err_dec_line_count: 408 + tty_port_destroy(&qtty->port); 408 409 goldfish_tty_current_line_count--; 409 410 if (goldfish_tty_current_line_count == 0) 410 411 goldfish_tty_delete_driver(); ··· 427 426 iounmap(qtty->base); 428 427 qtty->base = NULL; 429 428 free_irq(qtty->irq, pdev); 429 + tty_port_destroy(&qtty->port); 430 430 goldfish_tty_current_line_count--; 431 431 if (goldfish_tty_current_line_count == 0) 432 432 goldfish_tty_delete_driver();
+19
drivers/tty/hvc/Kconfig
··· 87 87 driver. This console is used through a JTAG only on ARM. If you don't have 88 88 a JTAG then you probably don't want this option. 89 89 90 + config HVC_DCC_SERIALIZE_SMP 91 + bool "Use DCC only on CPU core 0" 92 + depends on SMP && HVC_DCC 93 + help 94 + This is a DEBUG option to serialize all console input and output to CPU 0. 95 + Some external debuggers, do not handle reads/writes from/to DCC on more 96 + than one CPU core. Each core has its own DCC device registers, so when a 97 + CPU core reads or writes from/to DCC, it only accesses its own DCC device. 98 + Since kernel code can run on any CPU core, every time the kernel wants to 99 + write to the console, it might write to a different DCC. 100 + 101 + In SMP mode, external debuggers create multiple windows, and each window 102 + shows the DCC output only from that core's DCC. The result is that 103 + console output is either lost or scattered across windows. 104 + 105 + Enable this option only if you are sure that you do not need features like 106 + CPU hotplug to work. For example, during early chipset bringups without 107 + debug serial console support. If unsure, say N. 108 + 90 109 config HVC_RISCV_SBI 91 110 bool "RISC-V SBI console support" 92 111 depends on RISCV_SBI_V01
+190 -4
drivers/tty/hvc/hvc_dcc.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - /* Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved. */ 2 + /* Copyright (c) 2010, 2014, 2022 The Linux Foundation. All rights reserved. */ 3 3 4 4 #include <linux/console.h> 5 + #include <linux/cpu.h> 6 + #include <linux/cpumask.h> 5 7 #include <linux/init.h> 8 + #include <linux/kfifo.h> 6 9 #include <linux/serial.h> 7 10 #include <linux/serial_core.h> 11 + #include <linux/smp.h> 12 + #include <linux/spinlock.h> 8 13 9 14 #include <asm/dcc.h> 10 15 #include <asm/processor.h> ··· 19 14 /* DCC Status Bits */ 20 15 #define DCC_STATUS_RX (1 << 30) 21 16 #define DCC_STATUS_TX (1 << 29) 17 + 18 + #define DCC_INBUF_SIZE 128 19 + #define DCC_OUTBUF_SIZE 1024 20 + 21 + /* Lock to serialize access to DCC fifo */ 22 + static DEFINE_SPINLOCK(dcc_lock); 23 + 24 + static DEFINE_KFIFO(inbuf, unsigned char, DCC_INBUF_SIZE); 25 + static DEFINE_KFIFO(outbuf, unsigned char, DCC_OUTBUF_SIZE); 22 26 23 27 static void dcc_uart_console_putchar(struct uart_port *port, unsigned char ch) 24 28 { ··· 81 67 return i; 82 68 } 83 69 70 + /* 71 + * Check if the DCC is enabled. If CONFIG_HVC_DCC_SERIALIZE_SMP is enabled, 72 + * then we assume then this function will be called first on core0. That way, 73 + * dcc_core0_available will be true only if it's available on core0. 74 + */ 84 75 static bool hvc_dcc_check(void) 85 76 { 86 77 unsigned long time = jiffies + (HZ / 10); 78 + static bool dcc_core0_available; 79 + 80 + /* 81 + * If we're not on core 0, but we previously confirmed that DCC is 82 + * active, then just return true. 83 + */ 84 + int cpu = get_cpu(); 85 + 86 + if (IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP) && cpu && dcc_core0_available) { 87 + put_cpu(); 88 + return true; 89 + } 90 + 91 + put_cpu(); 87 92 88 93 /* Write a test character to check if it is handled */ 89 94 __dcc_putchar('\n'); 90 95 91 96 while (time_is_after_jiffies(time)) { 92 - if (!(__dcc_getstatus() & DCC_STATUS_TX)) 97 + if (!(__dcc_getstatus() & DCC_STATUS_TX)) { 98 + dcc_core0_available = true; 93 99 return true; 100 + } 94 101 } 95 102 96 103 return false; 97 104 } 98 105 106 + /* 107 + * Workqueue function that writes the output FIFO to the DCC on core 0. 108 + */ 109 + static void dcc_put_work(struct work_struct *work) 110 + { 111 + unsigned char ch; 112 + unsigned long irqflags; 113 + 114 + spin_lock_irqsave(&dcc_lock, irqflags); 115 + 116 + /* While there's data in the output FIFO, write it to the DCC */ 117 + while (kfifo_get(&outbuf, &ch)) 118 + hvc_dcc_put_chars(0, &ch, 1); 119 + 120 + /* While we're at it, check for any input characters */ 121 + while (!kfifo_is_full(&inbuf)) { 122 + if (!hvc_dcc_get_chars(0, &ch, 1)) 123 + break; 124 + kfifo_put(&inbuf, ch); 125 + } 126 + 127 + spin_unlock_irqrestore(&dcc_lock, irqflags); 128 + } 129 + 130 + static DECLARE_WORK(dcc_pwork, dcc_put_work); 131 + 132 + /* 133 + * Workqueue function that reads characters from DCC and puts them into the 134 + * input FIFO. 135 + */ 136 + static void dcc_get_work(struct work_struct *work) 137 + { 138 + unsigned char ch; 139 + unsigned long irqflags; 140 + 141 + /* 142 + * Read characters from DCC and put them into the input FIFO, as 143 + * long as there is room and we have characters to read. 144 + */ 145 + spin_lock_irqsave(&dcc_lock, irqflags); 146 + 147 + while (!kfifo_is_full(&inbuf)) { 148 + if (!hvc_dcc_get_chars(0, &ch, 1)) 149 + break; 150 + kfifo_put(&inbuf, ch); 151 + } 152 + spin_unlock_irqrestore(&dcc_lock, irqflags); 153 + } 154 + 155 + static DECLARE_WORK(dcc_gwork, dcc_get_work); 156 + 157 + /* 158 + * Write characters directly to the DCC if we're on core 0 and the FIFO 159 + * is empty, or write them to the FIFO if we're not. 160 + */ 161 + static int hvc_dcc0_put_chars(u32 vt, const char *buf, int count) 162 + { 163 + int len; 164 + unsigned long irqflags; 165 + 166 + if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) 167 + return hvc_dcc_put_chars(vt, buf, count); 168 + 169 + spin_lock_irqsave(&dcc_lock, irqflags); 170 + if (smp_processor_id() || (!kfifo_is_empty(&outbuf))) { 171 + len = kfifo_in(&outbuf, buf, count); 172 + spin_unlock_irqrestore(&dcc_lock, irqflags); 173 + 174 + /* 175 + * We just push data to the output FIFO, so schedule the 176 + * workqueue that will actually write that data to DCC. 177 + * CPU hotplug is disabled in dcc_init so CPU0 cannot be 178 + * offlined after the cpu online check. 179 + */ 180 + if (cpu_online(0)) 181 + schedule_work_on(0, &dcc_pwork); 182 + 183 + return len; 184 + } 185 + 186 + /* 187 + * If we're already on core 0, and the FIFO is empty, then just 188 + * write the data to DCC. 189 + */ 190 + len = hvc_dcc_put_chars(vt, buf, count); 191 + spin_unlock_irqrestore(&dcc_lock, irqflags); 192 + 193 + return len; 194 + } 195 + 196 + /* 197 + * Read characters directly from the DCC if we're on core 0 and the FIFO 198 + * is empty, or read them from the FIFO if we're not. 199 + */ 200 + static int hvc_dcc0_get_chars(u32 vt, char *buf, int count) 201 + { 202 + int len; 203 + unsigned long irqflags; 204 + 205 + if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) 206 + return hvc_dcc_get_chars(vt, buf, count); 207 + 208 + spin_lock_irqsave(&dcc_lock, irqflags); 209 + 210 + if (smp_processor_id() || (!kfifo_is_empty(&inbuf))) { 211 + len = kfifo_out(&inbuf, buf, count); 212 + spin_unlock_irqrestore(&dcc_lock, irqflags); 213 + 214 + /* 215 + * If the FIFO was empty, there may be characters in the DCC 216 + * that we haven't read yet. Schedule a workqueue to fill 217 + * the input FIFO, so that the next time this function is 218 + * called, we'll have data. CPU hotplug is disabled in dcc_init 219 + * so CPU0 cannot be offlined after the cpu online check. 220 + */ 221 + if (!len && cpu_online(0)) 222 + schedule_work_on(0, &dcc_gwork); 223 + 224 + return len; 225 + } 226 + 227 + /* 228 + * If we're already on core 0, and the FIFO is empty, then just 229 + * read the data from DCC. 230 + */ 231 + len = hvc_dcc_get_chars(vt, buf, count); 232 + spin_unlock_irqrestore(&dcc_lock, irqflags); 233 + 234 + return len; 235 + } 236 + 99 237 static const struct hv_ops hvc_dcc_get_put_ops = { 100 - .get_chars = hvc_dcc_get_chars, 101 - .put_chars = hvc_dcc_put_chars, 238 + .get_chars = hvc_dcc0_get_chars, 239 + .put_chars = hvc_dcc0_put_chars, 102 240 }; 103 241 104 242 static int __init hvc_dcc_console_init(void) ··· 273 107 274 108 if (!hvc_dcc_check()) 275 109 return -ENODEV; 110 + 111 + if (IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) { 112 + pr_warn("\n"); 113 + pr_warn("********************************************************************\n"); 114 + pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); 115 + pr_warn("** **\n"); 116 + pr_warn("** HVC_DCC_SERIALIZE_SMP SUPPORT HAS BEEN ENABLED IN THIS KERNEL **\n"); 117 + pr_warn("** **\n"); 118 + pr_warn("** This means that this is a DEBUG kernel and unsafe for **\n"); 119 + pr_warn("** production use and has important feature like CPU hotplug **\n"); 120 + pr_warn("** disabled. **\n"); 121 + pr_warn("** **\n"); 122 + pr_warn("** If you see this message and you are not debugging the **\n"); 123 + pr_warn("** kernel, report this immediately to your vendor! **\n"); 124 + pr_warn("** **\n"); 125 + pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); 126 + pr_warn("********************************************************************\n"); 127 + 128 + cpu_hotplug_disable(); 129 + } 276 130 277 131 p = hvc_alloc(0, 0, &hvc_dcc_get_put_ops, 128); 278 132
+3 -3
drivers/tty/hvc/hvc_opal.c
··· 13 13 #include <linux/slab.h> 14 14 #include <linux/console.h> 15 15 #include <linux/of.h> 16 + #include <linux/of_irq.h> 16 17 #include <linux/of_platform.h> 17 18 #include <linux/export.h> 18 19 #include <linux/interrupt.h> 19 20 20 21 #include <asm/hvconsole.h> 21 - #include <asm/prom.h> 22 22 #include <asm/firmware.h> 23 23 #include <asm/hvsi.h> 24 24 #include <asm/udbg.h> ··· 342 342 * path, so we hard wire it 343 343 */ 344 344 opal = of_find_node_by_path("/ibm,opal/consoles"); 345 - if (opal) 345 + if (opal) { 346 346 pr_devel("hvc_opal: Found consoles in new location\n"); 347 - if (!opal) { 347 + } else { 348 348 opal = of_find_node_by_path("/ibm,opal"); 349 349 if (opal) 350 350 pr_devel("hvc_opal: "
+1 -1
drivers/tty/hvc/hvc_vio.c
··· 28 28 #include <linux/delay.h> 29 29 #include <linux/slab.h> 30 30 #include <linux/console.h> 31 + #include <linux/of.h> 31 32 32 33 #include <asm/hvconsole.h> 33 34 #include <asm/vio.h> 34 - #include <asm/prom.h> 35 35 #include <asm/hvsi.h> 36 36 #include <asm/udbg.h> 37 37 #include <asm/machdep.h>
+2 -3
drivers/tty/hvc/hvcs.c
··· 581 581 582 582 spin_unlock_irqrestore(&hvcsd->lock, flags); 583 583 /* This is synch -- FIXME :js: it is not! */ 584 - if(got) 584 + if (got) 585 585 tty_flip_buffer_push(&hvcsd->port); 586 - 587 - if (!got) { 586 + else { 588 587 /* Do this _after_ the flip_buffer_push */ 589 588 spin_lock_irqsave(&hvcsd->lock, flags); 590 589 vio_enable_interrupts(hvcsd->vdev);
+1 -1
drivers/tty/hvc/hvsi.c
··· 26 26 #include <linux/module.h> 27 27 #include <linux/major.h> 28 28 #include <linux/kernel.h> 29 + #include <linux/of_irq.h> 29 30 #include <linux/spinlock.h> 30 31 #include <linux/sysrq.h> 31 32 #include <linux/tty.h> 32 33 #include <linux/tty_flip.h> 33 34 #include <asm/hvcall.h> 34 35 #include <asm/hvconsole.h> 35 - #include <asm/prom.h> 36 36 #include <linux/uaccess.h> 37 37 #include <asm/vio.h> 38 38 #include <asm/param.h>
+2 -3
drivers/tty/mxser.c
··· 528 528 outb(quot >> 8, info->ioaddr + UART_DLM); /* MS of divisor */ 529 529 outb(cval, info->ioaddr + UART_LCR); /* reset DLAB */ 530 530 531 - #ifdef BOTHER 532 531 if (C_BAUD(tty) == BOTHER) { 533 532 quot = MXSER_BAUD_BASE % newspd; 534 533 quot *= 8; ··· 538 539 quot /= newspd; 539 540 540 541 mxser_set_must_enum_value(info->ioaddr, quot); 541 - } else 542 - #endif 542 + } else { 543 543 mxser_set_must_enum_value(info->ioaddr, 0); 544 + } 544 545 545 546 return 0; 546 547 }
+24 -13
drivers/tty/n_gsm.c
··· 444 444 return modembits; 445 445 } 446 446 447 + static void gsm_hex_dump_bytes(const char *fname, const u8 *data, 448 + unsigned long len) 449 + { 450 + char *prefix; 451 + 452 + if (!fname) { 453 + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 1, data, len, 454 + true); 455 + return; 456 + } 457 + 458 + prefix = kasprintf(GFP_KERNEL, "%s: ", fname); 459 + if (!prefix) 460 + return; 461 + print_hex_dump(KERN_INFO, prefix, DUMP_PREFIX_OFFSET, 16, 1, data, len, 462 + true); 463 + kfree(prefix); 464 + } 465 + 447 466 /** 448 467 * gsm_print_packet - display a frame for debug 449 468 * @hdr: header to print before decode ··· 527 508 else 528 509 pr_cont("(F)"); 529 510 530 - print_hex_dump_bytes("", DUMP_PREFIX_NONE, data, dlen); 511 + gsm_hex_dump_bytes(NULL, data, dlen); 531 512 } 532 513 533 514 ··· 717 698 } 718 699 719 700 if (debug & 4) 720 - print_hex_dump_bytes("gsm_data_kick: ", 721 - DUMP_PREFIX_OFFSET, 722 - gsm->txframe, len); 701 + gsm_hex_dump_bytes(__func__, gsm->txframe, len); 723 702 if (gsmld_output(gsm, gsm->txframe, len) <= 0) 724 703 break; 725 704 /* FIXME: Can eliminate one SOF in many more cases */ ··· 766 749 767 750 *--dp = msg->ctrl; 768 751 if (gsm->initiator) 769 - *--dp = (msg->addr << 2) | 2 | EA; 752 + *--dp = (msg->addr << 2) | CR | EA; 770 753 else 771 754 *--dp = (msg->addr << 2) | EA; 772 755 *fcs = gsm_fcs_add_block(INIT_FCS, dp , msg->data - dp); ··· 1924 1907 case UI|PF: 1925 1908 case UIH: 1926 1909 case UIH|PF: 1927 - #if 0 1928 - if (cr) 1929 - goto invalid; 1930 - #endif 1931 1910 if (dlci == NULL || dlci->state != DLCI_OPEN) { 1932 1911 gsm_command(gsm, address, DM|PF); 1933 1912 return; ··· 2461 2448 return -ENOSPC; 2462 2449 } 2463 2450 if (debug & 4) 2464 - print_hex_dump_bytes("gsmld_output: ", DUMP_PREFIX_OFFSET, 2465 - data, len); 2451 + gsm_hex_dump_bytes(__func__, data, len); 2466 2452 return gsm->tty->ops->write(gsm->tty, data, len); 2467 2453 } 2468 2454 ··· 2537 2525 char flags = TTY_NORMAL; 2538 2526 2539 2527 if (debug & 4) 2540 - print_hex_dump_bytes("gsmld_receive: ", DUMP_PREFIX_OFFSET, 2541 - cp, count); 2528 + gsm_hex_dump_bytes(__func__, cp, count); 2542 2529 2543 2530 for (; count; count--, cp++) { 2544 2531 if (fp)
+61 -12
drivers/tty/n_tty.c
··· 1220 1220 process_echoes(tty); 1221 1221 } 1222 1222 1223 + static bool n_tty_is_char_flow_ctrl(struct tty_struct *tty, unsigned char c) 1224 + { 1225 + return c == START_CHAR(tty) || c == STOP_CHAR(tty); 1226 + } 1227 + 1228 + /* Returns true if c is consumed as flow-control character */ 1229 + static bool n_tty_receive_char_flow_ctrl(struct tty_struct *tty, unsigned char c) 1230 + { 1231 + if (!n_tty_is_char_flow_ctrl(tty, c)) 1232 + return false; 1233 + 1234 + if (c == START_CHAR(tty)) { 1235 + start_tty(tty); 1236 + process_echoes(tty); 1237 + return true; 1238 + } 1239 + 1240 + /* STOP_CHAR */ 1241 + stop_tty(tty); 1242 + return true; 1243 + } 1244 + 1223 1245 static void n_tty_receive_char_special(struct tty_struct *tty, unsigned char c) 1224 1246 { 1225 1247 struct n_tty_data *ldata = tty->disc_data; 1226 1248 1227 - if (I_IXON(tty)) { 1228 - if (c == START_CHAR(tty)) { 1229 - start_tty(tty); 1230 - process_echoes(tty); 1231 - return; 1232 - } 1233 - if (c == STOP_CHAR(tty)) { 1234 - stop_tty(tty); 1235 - return; 1236 - } 1237 - } 1249 + if (I_IXON(tty) && n_tty_receive_char_flow_ctrl(tty, c)) 1250 + return; 1238 1251 1239 1252 if (L_ISIG(tty)) { 1240 1253 if (c == INTR_CHAR(tty)) { ··· 1988 1975 return ldata->read_tail != canon_head; 1989 1976 } 1990 1977 1978 + /* 1979 + * If we finished a read at the exact location of an 1980 + * EOF (special EOL character that's a __DISABLED_CHAR) 1981 + * in the stream, silently eat the EOF. 1982 + */ 1983 + static void canon_skip_eof(struct tty_struct *tty) 1984 + { 1985 + struct n_tty_data *ldata = tty->disc_data; 1986 + size_t tail, canon_head; 1987 + 1988 + canon_head = smp_load_acquire(&ldata->canon_head); 1989 + tail = ldata->read_tail; 1990 + 1991 + // No data? 1992 + if (tail == canon_head) 1993 + return; 1994 + 1995 + // See if the tail position is EOF in the circular buffer 1996 + tail &= (N_TTY_BUF_SIZE - 1); 1997 + if (!test_bit(tail, ldata->read_flags)) 1998 + return; 1999 + if (read_buf(ldata, tail) != __DISABLED_CHAR) 2000 + return; 2001 + 2002 + // Clear the EOL bit, skip the EOF char. 2003 + clear_bit(tail, ldata->read_flags); 2004 + smp_store_release(&ldata->read_tail, ldata->read_tail + 1); 2005 + } 2006 + 1991 2007 /** 1992 2008 * job_control - check job control 1993 2009 * @tty: tty ··· 2087 2045 */ 2088 2046 if (*cookie) { 2089 2047 if (ldata->icanon && !L_EXTPROC(tty)) { 2090 - if (canon_copy_from_read_buf(tty, &kb, &nr)) 2048 + /* 2049 + * If we have filled the user buffer, see 2050 + * if we should skip an EOF character before 2051 + * releasing the lock and returning done. 2052 + */ 2053 + if (!nr) 2054 + canon_skip_eof(tty); 2055 + else if (canon_copy_from_read_buf(tty, &kb, &nr)) 2091 2056 return kb - kbuf; 2092 2057 } else { 2093 2058 if (copy_from_read_buf(tty, &kb, &nr))
+41
drivers/tty/serial/8250/8250.h
··· 17 17 struct uart_8250_dma { 18 18 int (*tx_dma)(struct uart_8250_port *p); 19 19 int (*rx_dma)(struct uart_8250_port *p); 20 + void (*prepare_tx_dma)(struct uart_8250_port *p); 21 + void (*prepare_rx_dma)(struct uart_8250_port *p); 20 22 21 23 /* Filter function */ 22 24 dma_filter_fn fn; ··· 85 83 #define UART_CAP_MINI BIT(17) /* Mini UART on BCM283X family lacks: 86 84 * STOP PARITY EPAR SPAR WLEN5 WLEN6 87 85 */ 86 + #define UART_CAP_NOTEMT BIT(18) /* UART without interrupt on TEMT available */ 88 87 89 88 #define UART_BUG_QUOT BIT(0) /* UART has buggy quot LSB */ 90 89 #define UART_BUG_TXEN BIT(1) /* UART has buggy TX IIR status */ ··· 121 118 static inline void serial_out(struct uart_8250_port *up, int offset, int value) 122 119 { 123 120 up->port.serial_out(&up->port, offset, value); 121 + } 122 + 123 + /* 124 + * For the 16C950 125 + */ 126 + static void serial_icr_write(struct uart_8250_port *up, int offset, int value) 127 + { 128 + serial_out(up, UART_SCR, offset); 129 + serial_out(up, UART_ICR, value); 130 + } 131 + 132 + static unsigned int __maybe_unused serial_icr_read(struct uart_8250_port *up, 133 + int offset) 134 + { 135 + unsigned int value; 136 + 137 + serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD); 138 + serial_out(up, UART_SCR, offset); 139 + value = serial_in(up, UART_ICR); 140 + serial_icr_write(up, UART_ACR, up->acr); 141 + 142 + return value; 124 143 } 125 144 126 145 void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p); ··· 327 302 extern void serial8250_rx_dma_flush(struct uart_8250_port *); 328 303 extern int serial8250_request_dma(struct uart_8250_port *); 329 304 extern void serial8250_release_dma(struct uart_8250_port *); 305 + 306 + static inline void serial8250_do_prepare_tx_dma(struct uart_8250_port *p) 307 + { 308 + struct uart_8250_dma *dma = p->dma; 309 + 310 + if (dma->prepare_tx_dma) 311 + dma->prepare_tx_dma(p); 312 + } 313 + 314 + static inline void serial8250_do_prepare_rx_dma(struct uart_8250_port *p) 315 + { 316 + struct uart_8250_dma *dma = p->dma; 317 + 318 + if (dma->prepare_rx_dma) 319 + dma->prepare_rx_dma(p); 320 + } 330 321 #else 331 322 static inline int serial8250_tx_dma(struct uart_8250_port *p) 332 323 {
+2
drivers/tty/serial/8250/8250_aspeed_vuart.c
··· 429 429 timer_setup(&vuart->unthrottle_timer, aspeed_vuart_unthrottle_exp, 0); 430 430 431 431 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 432 + if (!res) 433 + return -EINVAL; 432 434 433 435 memset(&port, 0, sizeof(port)); 434 436 port.port.private_data = vuart;
-1
drivers/tty/serial/8250/8250_core.c
··· 32 32 #include <linux/mutex.h> 33 33 #include <linux/slab.h> 34 34 #include <linux/uaccess.h> 35 - #include <linux/pm_runtime.h> 36 35 #include <linux/io.h> 37 36 #ifdef CONFIG_SPARC 38 37 #include <linux/sunserialcore.h>
+5 -2
drivers/tty/serial/8250/8250_dma.c
··· 34 34 uart_write_wakeup(&p->port); 35 35 36 36 ret = serial8250_tx_dma(p); 37 - if (ret) 37 + if (ret || !dma->tx_running) 38 38 serial8250_set_THRI(p); 39 39 40 40 spin_unlock_irqrestore(&p->port.lock, flags); ··· 80 80 81 81 if (uart_tx_stopped(&p->port) || uart_circ_empty(xmit)) { 82 82 /* We have been called from __dma_tx_complete() */ 83 - serial8250_rpm_put_tx(p); 84 83 return 0; 85 84 } 86 85 87 86 dma->tx_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 87 + 88 + serial8250_do_prepare_tx_dma(p); 88 89 89 90 desc = dmaengine_prep_slave_single(dma->txchan, 90 91 dma->tx_addr + xmit->tail, ··· 123 122 124 123 if (dma->rx_running) 125 124 return 0; 125 + 126 + serial8250_do_prepare_rx_dma(p); 126 127 127 128 desc = dmaengine_prep_slave_single(dma->rxchan, dma->rx_addr, 128 129 dma->rx_size, DMA_DEV_TO_MEM,
+149 -80
drivers/tty/serial/8250/8250_dw.c
··· 12 12 #include <linux/delay.h> 13 13 #include <linux/device.h> 14 14 #include <linux/io.h> 15 + #include <linux/mod_devicetable.h> 15 16 #include <linux/module.h> 16 17 #include <linux/serial_8250.h> 17 18 #include <linux/serial_reg.h> 18 19 #include <linux/of.h> 19 - #include <linux/of_irq.h> 20 - #include <linux/of_platform.h> 21 20 #include <linux/platform_device.h> 21 + #include <linux/property.h> 22 22 #include <linux/workqueue.h> 23 23 #include <linux/notifier.h> 24 24 #include <linux/slab.h> ··· 33 33 34 34 /* Offsets for the DesignWare specific registers */ 35 35 #define DW_UART_USR 0x1f /* UART Status Register */ 36 + #define DW_UART_DMASA 0xa8 /* DMA Software Ack */ 37 + 38 + #define OCTEON_UART_USR 0x27 /* UART Status Register */ 39 + 40 + #define RZN1_UART_TDMACR 0x10c /* DMA Control Register Transmit Mode */ 41 + #define RZN1_UART_RDMACR 0x110 /* DMA Control Register Receive Mode */ 36 42 37 43 /* DesignWare specific register fields */ 38 44 #define DW_UART_MCR_SIRE BIT(6) 39 45 40 - struct dw8250_data { 41 - struct dw8250_port_data data; 46 + /* Renesas specific register fields */ 47 + #define RZN1_UART_xDMACR_DMA_EN BIT(0) 48 + #define RZN1_UART_xDMACR_1_WORD_BURST (0 << 1) 49 + #define RZN1_UART_xDMACR_4_WORD_BURST (1 << 1) 50 + #define RZN1_UART_xDMACR_8_WORD_BURST (3 << 1) 51 + #define RZN1_UART_xDMACR_BLK_SZ(x) ((x) << 3) 42 52 43 - u8 usr_reg; 44 - int msr_mask_on; 45 - int msr_mask_off; 46 - struct clk *clk; 47 - struct clk *pclk; 48 - struct notifier_block clk_notifier; 49 - struct work_struct clk_work; 50 - struct reset_control *rst; 51 - 52 - unsigned int skip_autocfg:1; 53 - unsigned int uart_16550_compatible:1; 54 - }; 55 - 56 - static inline struct dw8250_data *to_dw8250_data(struct dw8250_port_data *data) 57 - { 58 - return container_of(data, struct dw8250_data, data); 59 - } 53 + /* Quirks */ 54 + #define DW_UART_QUIRK_OCTEON BIT(0) 55 + #define DW_UART_QUIRK_ARMADA_38X BIT(1) 56 + #define DW_UART_QUIRK_SKIP_SET_RATE BIT(2) 57 + #define DW_UART_QUIRK_IS_DMA_FC BIT(3) 60 58 61 59 static inline struct dw8250_data *clk_to_dw8250_data(struct notifier_block *nb) 62 60 { ··· 236 238 struct uart_8250_port *up = up_to_u8250p(p); 237 239 struct dw8250_data *d = to_dw8250_data(p->private_data); 238 240 unsigned int iir = p->serial_in(p, UART_IIR); 241 + bool rx_timeout = (iir & 0x3f) == UART_IIR_RX_TIMEOUT; 242 + unsigned int quirks = d->pdata->quirks; 239 243 unsigned int status; 240 244 unsigned long flags; 241 245 ··· 251 251 * This problem has only been observed so far when not in DMA mode 252 252 * so we limit the workaround only to non-DMA mode. 253 253 */ 254 - if (!up->dma && ((iir & 0x3f) == UART_IIR_RX_TIMEOUT)) { 254 + if (!up->dma && rx_timeout) { 255 255 spin_lock_irqsave(&p->lock, flags); 256 256 status = p->serial_in(p, UART_LSR); 257 257 ··· 261 261 spin_unlock_irqrestore(&p->lock, flags); 262 262 } 263 263 264 + /* Manually stop the Rx DMA transfer when acting as flow controller */ 265 + if (quirks & DW_UART_QUIRK_IS_DMA_FC && up->dma && up->dma->rx_running && rx_timeout) { 266 + status = p->serial_in(p, UART_LSR); 267 + if (status & (UART_LSR_DR | UART_LSR_BI)) { 268 + dw8250_writel_ext(p, RZN1_UART_RDMACR, 0); 269 + dw8250_writel_ext(p, DW_UART_DMASA, 1); 270 + } 271 + } 272 + 264 273 if (serial8250_handle_irq(p, iir)) 265 274 return 1; 266 275 267 276 if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) { 268 277 /* Clear the USR */ 269 - (void)p->serial_in(p, d->usr_reg); 278 + (void)p->serial_in(p, d->pdata->usr_reg); 270 279 271 280 return 1; 272 281 } ··· 393 384 return param == chan->device->dev; 394 385 } 395 386 387 + static u32 dw8250_rzn1_get_dmacr_burst(int max_burst) 388 + { 389 + if (max_burst >= 8) 390 + return RZN1_UART_xDMACR_8_WORD_BURST; 391 + else if (max_burst >= 4) 392 + return RZN1_UART_xDMACR_4_WORD_BURST; 393 + else 394 + return RZN1_UART_xDMACR_1_WORD_BURST; 395 + } 396 + 397 + static void dw8250_prepare_tx_dma(struct uart_8250_port *p) 398 + { 399 + struct uart_port *up = &p->port; 400 + struct uart_8250_dma *dma = p->dma; 401 + u32 val; 402 + 403 + dw8250_writel_ext(up, RZN1_UART_TDMACR, 0); 404 + val = dw8250_rzn1_get_dmacr_burst(dma->txconf.dst_maxburst) | 405 + RZN1_UART_xDMACR_BLK_SZ(dma->tx_size) | 406 + RZN1_UART_xDMACR_DMA_EN; 407 + dw8250_writel_ext(up, RZN1_UART_TDMACR, val); 408 + } 409 + 410 + static void dw8250_prepare_rx_dma(struct uart_8250_port *p) 411 + { 412 + struct uart_port *up = &p->port; 413 + struct uart_8250_dma *dma = p->dma; 414 + u32 val; 415 + 416 + dw8250_writel_ext(up, RZN1_UART_RDMACR, 0); 417 + val = dw8250_rzn1_get_dmacr_burst(dma->rxconf.src_maxburst) | 418 + RZN1_UART_xDMACR_BLK_SZ(dma->rx_size) | 419 + RZN1_UART_xDMACR_DMA_EN; 420 + dw8250_writel_ext(up, RZN1_UART_RDMACR, val); 421 + } 422 + 396 423 static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) 397 424 { 398 425 struct device_node *np = p->dev->of_node; 399 426 400 427 if (np) { 428 + unsigned int quirks = data->pdata->quirks; 401 429 int id; 402 430 403 431 /* get index of serial line, if found in DT aliases */ ··· 442 396 if (id >= 0) 443 397 p->line = id; 444 398 #ifdef CONFIG_64BIT 445 - if (of_device_is_compatible(np, "cavium,octeon-3860-uart")) { 399 + if (quirks & DW_UART_QUIRK_OCTEON) { 446 400 p->serial_in = dw8250_serial_inq; 447 401 p->serial_out = dw8250_serial_outq; 448 402 p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; 449 403 p->type = PORT_OCTEON; 450 - data->usr_reg = 0x27; 451 404 data->skip_autocfg = true; 452 405 } 453 406 #endif ··· 457 412 p->serial_out = dw8250_serial_out32be; 458 413 } 459 414 460 - if (of_device_is_compatible(np, "marvell,armada-38x-uart")) 415 + if (quirks & DW_UART_QUIRK_ARMADA_38X) 461 416 p->serial_out = dw8250_serial_out38x; 462 - if (of_device_is_compatible(np, "starfive,jh7100-uart")) 417 + if (quirks & DW_UART_QUIRK_SKIP_SET_RATE) 463 418 p->set_termios = dw8250_do_set_termios; 419 + if (quirks & DW_UART_QUIRK_IS_DMA_FC) { 420 + data->data.dma.txconf.device_fc = 1; 421 + data->data.dma.rxconf.device_fc = 1; 422 + data->data.dma.prepare_tx_dma = dw8250_prepare_tx_dma; 423 + data->data.dma.prepare_rx_dma = dw8250_prepare_rx_dma; 424 + } 464 425 465 426 } else if (acpi_dev_present("APMC0D08", NULL, -1)) { 466 427 p->iotype = UPIO_MEM32; ··· 484 433 } 485 434 } 486 435 436 + static void dw8250_clk_disable_unprepare(void *data) 437 + { 438 + clk_disable_unprepare(data); 439 + } 440 + 441 + static void dw8250_reset_control_assert(void *data) 442 + { 443 + reset_control_assert(data); 444 + } 445 + 487 446 static int dw8250_probe(struct platform_device *pdev) 488 447 { 489 448 struct uart_8250_port uart = {}, *up = &uart; 490 - struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 491 449 struct uart_port *p = &up->port; 492 450 struct device *dev = &pdev->dev; 493 451 struct dw8250_data *data; 452 + struct resource *regs; 494 453 int irq; 495 454 int err; 496 455 u32 val; 497 456 498 - if (!regs) { 499 - dev_err(dev, "no registers defined\n"); 500 - return -EINVAL; 501 - } 457 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 458 + if (!regs) 459 + return dev_err_probe(dev, -EINVAL, "no registers defined\n"); 502 460 503 461 irq = platform_get_irq(pdev, 0); 504 462 if (irq < 0) ··· 536 476 return -ENOMEM; 537 477 538 478 data->data.dma.fn = dw8250_fallback_dma_filter; 539 - data->usr_reg = DW_UART_USR; 479 + data->pdata = device_get_match_data(p->dev); 540 480 p->private_data = &data->data; 541 481 542 482 data->uart_16550_compatible = device_property_read_bool(dev, ··· 592 532 593 533 err = clk_prepare_enable(data->clk); 594 534 if (err) 595 - dev_warn(dev, "could not enable optional baudclk: %d\n", err); 535 + return dev_err_probe(dev, err, "could not enable optional baudclk\n"); 536 + 537 + err = devm_add_action_or_reset(dev, dw8250_clk_disable_unprepare, data->clk); 538 + if (err) 539 + return err; 596 540 597 541 if (data->clk) 598 542 p->uartclk = clk_get_rate(data->clk); 599 543 600 544 /* If no clock rate is defined, fail. */ 601 - if (!p->uartclk) { 602 - dev_err(dev, "clock rate not defined\n"); 603 - err = -EINVAL; 604 - goto err_clk; 605 - } 545 + if (!p->uartclk) 546 + return dev_err_probe(dev, -EINVAL, "clock rate not defined\n"); 606 547 607 548 data->pclk = devm_clk_get_optional(dev, "apb_pclk"); 608 - if (IS_ERR(data->pclk)) { 609 - err = PTR_ERR(data->pclk); 610 - goto err_clk; 611 - } 549 + if (IS_ERR(data->pclk)) 550 + return PTR_ERR(data->pclk); 612 551 613 552 err = clk_prepare_enable(data->pclk); 614 - if (err) { 615 - dev_err(dev, "could not enable apb_pclk\n"); 616 - goto err_clk; 617 - } 553 + if (err) 554 + return dev_err_probe(dev, err, "could not enable apb_pclk\n"); 555 + 556 + err = devm_add_action_or_reset(dev, dw8250_clk_disable_unprepare, data->pclk); 557 + if (err) 558 + return err; 618 559 619 560 data->rst = devm_reset_control_get_optional_exclusive(dev, NULL); 620 - if (IS_ERR(data->rst)) { 621 - err = PTR_ERR(data->rst); 622 - goto err_pclk; 623 - } 561 + if (IS_ERR(data->rst)) 562 + return PTR_ERR(data->rst); 563 + 624 564 reset_control_deassert(data->rst); 565 + 566 + err = devm_add_action_or_reset(dev, dw8250_reset_control_assert, data->rst); 567 + if (err) 568 + return err; 625 569 626 570 dw8250_quirks(p, data); 627 571 ··· 644 580 } 645 581 646 582 data->data.line = serial8250_register_8250_port(up); 647 - if (data->data.line < 0) { 648 - err = data->data.line; 649 - goto err_reset; 650 - } 583 + if (data->data.line < 0) 584 + return data->data.line; 651 585 652 586 /* 653 587 * Some platforms may provide a reference clock shared between several ··· 655 593 if (data->clk) { 656 594 err = clk_notifier_register(data->clk, &data->clk_notifier); 657 595 if (err) 658 - dev_warn(p->dev, "Failed to set the clock notifier\n"); 659 - else 660 - queue_work(system_unbound_wq, &data->clk_work); 596 + return dev_err_probe(dev, err, "Failed to set the clock notifier\n"); 597 + queue_work(system_unbound_wq, &data->clk_work); 661 598 } 662 599 663 600 platform_set_drvdata(pdev, data); ··· 665 604 pm_runtime_enable(dev); 666 605 667 606 return 0; 668 - 669 - err_reset: 670 - reset_control_assert(data->rst); 671 - 672 - err_pclk: 673 - clk_disable_unprepare(data->pclk); 674 - 675 - err_clk: 676 - clk_disable_unprepare(data->clk); 677 - 678 - return err; 679 607 } 680 608 681 609 static int dw8250_remove(struct platform_device *pdev) ··· 681 631 } 682 632 683 633 serial8250_unregister_port(data->data.line); 684 - 685 - reset_control_assert(data->rst); 686 - 687 - clk_disable_unprepare(data->pclk); 688 - 689 - clk_disable_unprepare(data->clk); 690 634 691 635 pm_runtime_disable(dev); 692 636 pm_runtime_put_noidle(dev); ··· 737 693 SET_RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL) 738 694 }; 739 695 696 + static const struct dw8250_platform_data dw8250_dw_apb = { 697 + .usr_reg = DW_UART_USR, 698 + }; 699 + 700 + static const struct dw8250_platform_data dw8250_octeon_3860_data = { 701 + .usr_reg = OCTEON_UART_USR, 702 + .quirks = DW_UART_QUIRK_OCTEON, 703 + }; 704 + 705 + static const struct dw8250_platform_data dw8250_armada_38x_data = { 706 + .usr_reg = DW_UART_USR, 707 + .quirks = DW_UART_QUIRK_ARMADA_38X, 708 + }; 709 + 710 + static const struct dw8250_platform_data dw8250_renesas_rzn1_data = { 711 + .usr_reg = DW_UART_USR, 712 + .cpr_val = 0x00012f32, 713 + .quirks = DW_UART_QUIRK_IS_DMA_FC, 714 + }; 715 + 716 + static const struct dw8250_platform_data dw8250_starfive_jh7100_data = { 717 + .usr_reg = DW_UART_USR, 718 + .quirks = DW_UART_QUIRK_SKIP_SET_RATE, 719 + }; 720 + 740 721 static const struct of_device_id dw8250_of_match[] = { 741 - { .compatible = "snps,dw-apb-uart" }, 742 - { .compatible = "cavium,octeon-3860-uart" }, 743 - { .compatible = "marvell,armada-38x-uart" }, 744 - { .compatible = "renesas,rzn1-uart" }, 745 - { .compatible = "starfive,jh7100-uart" }, 722 + { .compatible = "snps,dw-apb-uart", .data = &dw8250_dw_apb }, 723 + { .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data }, 724 + { .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data }, 725 + { .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data }, 726 + { .compatible = "starfive,jh7100-uart", .data = &dw8250_starfive_jh7100_data }, 746 727 { /* Sentinel */ } 747 728 }; 748 729 MODULE_DEVICE_TABLE(of, dw8250_of_match);
+96 -20
drivers/tty/serial/8250/8250_dwlib.c
··· 2 2 /* Synopsys DesignWare 8250 library. */ 3 3 4 4 #include <linux/bitops.h> 5 + #include <linux/bitfield.h> 5 6 #include <linux/device.h> 6 - #include <linux/io.h> 7 7 #include <linux/kernel.h> 8 + #include <linux/property.h> 8 9 #include <linux/serial_8250.h> 9 10 #include <linux/serial_core.h> 10 11 11 12 #include "8250_dwlib.h" 12 13 13 14 /* Offsets for the DesignWare specific registers */ 15 + #define DW_UART_TCR 0xac /* Transceiver Control Register (RS485) */ 16 + #define DW_UART_DE_EN 0xb0 /* Driver Output Enable Register */ 17 + #define DW_UART_RE_EN 0xb4 /* Receiver Output Enable Register */ 14 18 #define DW_UART_DLF 0xc0 /* Divisor Latch Fraction Register */ 15 19 #define DW_UART_CPR 0xf4 /* Component Parameter Register */ 16 20 #define DW_UART_UCV 0xf8 /* UART Component Version */ 21 + 22 + /* Transceiver Control Register bits */ 23 + #define DW_UART_TCR_RS485_EN BIT(0) 24 + #define DW_UART_TCR_RE_POL BIT(1) 25 + #define DW_UART_TCR_DE_POL BIT(2) 26 + #define DW_UART_TCR_XFER_MODE GENMASK(4, 3) 27 + #define DW_UART_TCR_XFER_MODE_DE_DURING_RE FIELD_PREP(DW_UART_TCR_XFER_MODE, 0) 28 + #define DW_UART_TCR_XFER_MODE_SW_DE_OR_RE FIELD_PREP(DW_UART_TCR_XFER_MODE, 1) 29 + #define DW_UART_TCR_XFER_MODE_DE_OR_RE FIELD_PREP(DW_UART_TCR_XFER_MODE, 2) 17 30 18 31 /* Component Parameter Register bits */ 19 32 #define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) ··· 44 31 45 32 /* Helper for FIFO size calculation */ 46 33 #define DW_UART_CPR_FIFO_SIZE(a) (((a >> 16) & 0xff) * 16) 47 - 48 - static inline u32 dw8250_readl_ext(struct uart_port *p, int offset) 49 - { 50 - if (p->iotype == UPIO_MEM32BE) 51 - return ioread32be(p->membase + offset); 52 - return readl(p->membase + offset); 53 - } 54 - 55 - static inline void dw8250_writel_ext(struct uart_port *p, int offset, u32 reg) 56 - { 57 - if (p->iotype == UPIO_MEM32BE) 58 - iowrite32be(reg, p->membase + offset); 59 - else 60 - writel(reg, p->membase + offset); 61 - } 62 34 63 35 /* 64 36 * divisor = div(I) + div(F) ··· 85 87 } 86 88 EXPORT_SYMBOL_GPL(dw8250_do_set_termios); 87 89 90 + static int dw8250_rs485_config(struct uart_port *p, struct serial_rs485 *rs485) 91 + { 92 + u32 tcr; 93 + 94 + tcr = dw8250_readl_ext(p, DW_UART_TCR); 95 + tcr &= ~DW_UART_TCR_XFER_MODE; 96 + 97 + if (rs485->flags & SER_RS485_ENABLED) { 98 + /* Clear unsupported flags. */ 99 + rs485->flags &= SER_RS485_ENABLED | SER_RS485_RX_DURING_TX | 100 + SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND; 101 + tcr |= DW_UART_TCR_RS485_EN; 102 + 103 + if (rs485->flags & SER_RS485_RX_DURING_TX) { 104 + tcr |= DW_UART_TCR_XFER_MODE_DE_DURING_RE; 105 + } else { 106 + /* HW does not support same DE level for tx and rx */ 107 + if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == 108 + !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) 109 + return -EINVAL; 110 + 111 + tcr |= DW_UART_TCR_XFER_MODE_DE_OR_RE; 112 + } 113 + dw8250_writel_ext(p, DW_UART_DE_EN, 1); 114 + dw8250_writel_ext(p, DW_UART_RE_EN, 1); 115 + } else { 116 + rs485->flags = 0; 117 + 118 + tcr &= ~DW_UART_TCR_RS485_EN; 119 + } 120 + 121 + /* Reset to default polarity */ 122 + tcr |= DW_UART_TCR_DE_POL; 123 + tcr &= ~DW_UART_TCR_RE_POL; 124 + 125 + if (!(rs485->flags & SER_RS485_RTS_ON_SEND)) 126 + tcr &= ~DW_UART_TCR_DE_POL; 127 + if (device_property_read_bool(p->dev, "rs485-rx-active-high")) 128 + tcr |= DW_UART_TCR_RE_POL; 129 + 130 + dw8250_writel_ext(p, DW_UART_TCR, tcr); 131 + 132 + rs485->delay_rts_before_send = 0; 133 + rs485->delay_rts_after_send = 0; 134 + 135 + p->rs485 = *rs485; 136 + 137 + return 0; 138 + } 139 + 140 + /* 141 + * Tests if RE_EN register can have non-zero value to see if RS-485 HW support 142 + * is present. 143 + */ 144 + static bool dw8250_detect_rs485_hw(struct uart_port *p) 145 + { 146 + u32 reg; 147 + 148 + dw8250_writel_ext(p, DW_UART_RE_EN, 1); 149 + reg = dw8250_readl_ext(p, DW_UART_RE_EN); 150 + dw8250_writel_ext(p, DW_UART_RE_EN, 0); 151 + return reg; 152 + } 153 + 88 154 void dw8250_setup_port(struct uart_port *p) 89 155 { 156 + struct dw8250_port_data *pd = p->private_data; 157 + struct dw8250_data *data = to_dw8250_data(pd); 90 158 struct uart_8250_port *up = up_to_u8250p(p); 91 159 u32 reg; 160 + 161 + pd->hw_rs485_support = dw8250_detect_rs485_hw(p); 162 + if (pd->hw_rs485_support) { 163 + p->rs485_config = dw8250_rs485_config; 164 + } else { 165 + p->rs485_config = serial8250_em485_config; 166 + up->rs485_start_tx = serial8250_em485_start_tx; 167 + up->rs485_stop_tx = serial8250_em485_stop_tx; 168 + } 169 + up->capabilities |= UART_CAP_NOTEMT; 92 170 93 171 /* 94 172 * If the Component Version Register returns zero, we know that ··· 182 108 dw8250_writel_ext(p, DW_UART_DLF, 0); 183 109 184 110 if (reg) { 185 - struct dw8250_port_data *d = p->private_data; 186 - 187 - d->dlf_size = fls(reg); 111 + pd->dlf_size = fls(reg); 188 112 p->get_divisor = dw8250_get_divisor; 189 113 p->set_divisor = dw8250_set_divisor; 190 114 } 191 115 192 116 reg = dw8250_readl_ext(p, DW_UART_CPR); 117 + if (!reg) { 118 + reg = data->pdata->cpr_val; 119 + dev_dbg(p->dev, "CPR is not available, using 0x%08x instead\n", reg); 120 + } 193 121 if (!reg) 194 122 return; 195 123 ··· 200 124 p->type = PORT_16550A; 201 125 p->flags |= UPF_FIXED_TYPE; 202 126 p->fifosize = DW_UART_CPR_FIFO_SIZE(reg); 203 - up->capabilities = UART_CAP_FIFO; 127 + up->capabilities = UART_CAP_FIFO | UART_CAP_NOTEMT; 204 128 } 205 129 206 130 if (reg & DW_UART_CPR_AFCE_MODE)
+51
drivers/tty/serial/8250/8250_dwlib.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* Synopsys DesignWare 8250 library header file. */ 3 3 4 + #include <linux/io.h> 5 + #include <linux/notifier.h> 4 6 #include <linux/types.h> 7 + #include <linux/workqueue.h> 5 8 6 9 #include "8250.h" 10 + 11 + struct clk; 12 + struct reset_control; 7 13 8 14 struct dw8250_port_data { 9 15 /* Port properties */ ··· 20 14 21 15 /* Hardware configuration */ 22 16 u8 dlf_size; 17 + 18 + /* RS485 variables */ 19 + bool hw_rs485_support; 20 + }; 21 + 22 + struct dw8250_platform_data { 23 + u8 usr_reg; 24 + u32 cpr_val; 25 + unsigned int quirks; 26 + }; 27 + 28 + struct dw8250_data { 29 + struct dw8250_port_data data; 30 + const struct dw8250_platform_data *pdata; 31 + 32 + int msr_mask_on; 33 + int msr_mask_off; 34 + struct clk *clk; 35 + struct clk *pclk; 36 + struct notifier_block clk_notifier; 37 + struct work_struct clk_work; 38 + struct reset_control *rst; 39 + 40 + unsigned int skip_autocfg:1; 41 + unsigned int uart_16550_compatible:1; 23 42 }; 24 43 25 44 void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, struct ktermios *old); 26 45 void dw8250_setup_port(struct uart_port *p); 46 + 47 + static inline struct dw8250_data *to_dw8250_data(struct dw8250_port_data *data) 48 + { 49 + return container_of(data, struct dw8250_data, data); 50 + } 51 + 52 + static inline u32 dw8250_readl_ext(struct uart_port *p, int offset) 53 + { 54 + if (p->iotype == UPIO_MEM32BE) 55 + return ioread32be(p->membase + offset); 56 + return readl(p->membase + offset); 57 + } 58 + 59 + static inline void dw8250_writel_ext(struct uart_port *p, int offset, u32 reg) 60 + { 61 + if (p->iotype == UPIO_MEM32BE) 62 + iowrite32be(reg, p->membase + offset); 63 + else 64 + writel(reg, p->membase + offset); 65 + }
+4 -4
drivers/tty/serial/8250/8250_fintek.c
··· 200 200 if (!pdata) 201 201 return -EINVAL; 202 202 203 - /* Hardware do not support same RTS level on send and receive */ 204 - if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == 205 - !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) 206 - return -EINVAL; 207 203 208 204 if (rs485->flags & SER_RS485_ENABLED) { 205 + /* Hardware do not support same RTS level on send and receive */ 206 + if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == 207 + !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) 208 + return -EINVAL; 209 209 memset(rs485->padding, 0, sizeof(rs485->padding)); 210 210 config |= RS485_URA; 211 211 } else {
-7
drivers/tty/serial/8250/8250_mtk.c
··· 54 54 #define MTK_UART_TX_TRIGGER 1 55 55 #define MTK_UART_RX_TRIGGER MTK_UART_RX_SIZE 56 56 57 - #define MTK_UART_FEATURE_SEL 39 /* Feature Selection register */ 58 - #define MTK_UART_FEAT_NEWRMAP BIT(0) /* Use new register map */ 59 - 60 57 #define MTK_UART_XON1 40 /* I/O: Xon character 1 */ 61 58 #define MTK_UART_XOFF1 42 /* I/O: Xoff character 1 */ 62 59 ··· 571 574 if (data->dma) 572 575 uart.dma = data->dma; 573 576 #endif 574 - 575 - /* Set AP UART new register map */ 576 - writel(MTK_UART_FEAT_NEWRMAP, uart.port.membase + 577 - (MTK_UART_FEATURE_SEL << uart.port.regshift)); 578 577 579 578 /* Disable Rate Fix function */ 580 579 writel(0x0, uart.port.membase +
+2
drivers/tty/serial/8250/8250_of.c
··· 326 326 .data = (void *)PORT_ALTR_16550_F64, }, 327 327 { .compatible = "altr,16550-FIFO128", 328 328 .data = (void *)PORT_ALTR_16550_F128, }, 329 + { .compatible = "fsl,16550-FIFO64", 330 + .data = (void *)PORT_16550A_FSL64, }, 329 331 { .compatible = "mediatek,mtk-btif", 330 332 .data = (void *)PORT_MTK_BTIF, }, 331 333 { .compatible = "mrvl,mmp-uart",
+335 -145
drivers/tty/serial/8250/8250_pci.c
··· 11 11 #include <linux/pci.h> 12 12 #include <linux/string.h> 13 13 #include <linux/kernel.h> 14 + #include <linux/math.h> 14 15 #include <linux/slab.h> 15 16 #include <linux/delay.h> 16 17 #include <linux/tty.h> ··· 995 994 } 996 995 997 996 /* 998 - * EndRun Technologies. 999 - * Determine the number of ports available on the device. 997 + * Oxford Semiconductor Inc. 998 + * Check if an OxSemi device is part of the Tornado range of devices. 1000 999 */ 1001 1000 #define PCI_VENDOR_ID_ENDRUN 0x7401 1002 1001 #define PCI_DEVICE_ID_ENDRUN_1588 0xe100 1003 1002 1004 - static int pci_endrun_init(struct pci_dev *dev) 1003 + static bool pci_oxsemi_tornado_p(struct pci_dev *dev) 1005 1004 { 1006 - u8 __iomem *p; 1007 - unsigned long deviceID; 1008 - unsigned int number_uarts = 0; 1005 + /* OxSemi Tornado devices are all 0xCxxx */ 1006 + if (dev->vendor == PCI_VENDOR_ID_OXSEMI && 1007 + (dev->device & 0xf000) != 0xc000) 1008 + return false; 1009 1009 1010 - /* EndRun device is all 0xexxx */ 1010 + /* EndRun devices are all 0xExxx */ 1011 1011 if (dev->vendor == PCI_VENDOR_ID_ENDRUN && 1012 - (dev->device & 0xf000) != 0xe000) 1013 - return 0; 1012 + (dev->device & 0xf000) != 0xe000) 1013 + return false; 1014 1014 1015 - p = pci_iomap(dev, 0, 5); 1016 - if (p == NULL) 1017 - return -ENOMEM; 1018 - 1019 - deviceID = ioread32(p); 1020 - /* EndRun device */ 1021 - if (deviceID == 0x07000200) { 1022 - number_uarts = ioread8(p + 4); 1023 - pci_dbg(dev, "%d ports detected on EndRun PCI Express device\n", number_uarts); 1024 - } 1025 - pci_iounmap(dev, p); 1026 - return number_uarts; 1015 + return true; 1027 1016 } 1028 1017 1029 1018 /* 1030 - * Oxford Semiconductor Inc. 1031 - * Check that device is part of the Tornado range of devices, then determine 1032 - * the number of ports available on the device. 1019 + * Determine the number of ports available on a Tornado device. 1033 1020 */ 1034 1021 static int pci_oxsemi_tornado_init(struct pci_dev *dev) 1035 1022 { ··· 1025 1036 unsigned long deviceID; 1026 1037 unsigned int number_uarts = 0; 1027 1038 1028 - /* OxSemi Tornado devices are all 0xCxxx */ 1029 - if (dev->vendor == PCI_VENDOR_ID_OXSEMI && 1030 - (dev->device & 0xF000) != 0xC000) 1039 + if (!pci_oxsemi_tornado_p(dev)) 1031 1040 return 0; 1032 1041 1033 1042 p = pci_iomap(dev, 0, 5); ··· 1036 1049 /* Tornado device */ 1037 1050 if (deviceID == 0x07000200) { 1038 1051 number_uarts = ioread8(p + 4); 1039 - pci_dbg(dev, "%d ports detected on Oxford PCI Express device\n", number_uarts); 1052 + pci_dbg(dev, "%d ports detected on %s PCI Express device\n", 1053 + number_uarts, 1054 + dev->vendor == PCI_VENDOR_ID_ENDRUN ? 1055 + "EndRun" : "Oxford"); 1040 1056 } 1041 1057 pci_iounmap(dev, p); 1042 1058 return number_uarts; 1059 + } 1060 + 1061 + /* Tornado-specific constants for the TCR and CPR registers; see below. */ 1062 + #define OXSEMI_TORNADO_TCR_MASK 0xf 1063 + #define OXSEMI_TORNADO_CPR_MASK 0x1ff 1064 + #define OXSEMI_TORNADO_CPR_MIN 0x008 1065 + #define OXSEMI_TORNADO_CPR_DEF 0x10f 1066 + 1067 + /* 1068 + * Determine the oversampling rate, the clock prescaler, and the clock 1069 + * divisor for the requested baud rate. The clock rate is 62.5 MHz, 1070 + * which is four times the baud base, and the prescaler increments in 1071 + * steps of 1/8. Therefore to make calculations on integers we need 1072 + * to use a scaled clock rate, which is the baud base multiplied by 32 1073 + * (or our assumed UART clock rate multiplied by 2). 1074 + * 1075 + * The allowed oversampling rates are from 4 up to 16 inclusive (values 1076 + * from 0 to 3 inclusive map to 16). Likewise the clock prescaler allows 1077 + * values between 1.000 and 63.875 inclusive (operation for values from 1078 + * 0.000 to 0.875 has not been specified). The clock divisor is the usual 1079 + * unsigned 16-bit integer. 1080 + * 1081 + * For the most accurate baud rate we use a table of predetermined 1082 + * oversampling rates and clock prescalers that records all possible 1083 + * products of the two parameters in the range from 4 up to 255 inclusive, 1084 + * and additionally 335 for the 1500000bps rate, with the prescaler scaled 1085 + * by 8. The table is sorted by the decreasing value of the oversampling 1086 + * rate and ties are resolved by sorting by the decreasing value of the 1087 + * product. This way preference is given to higher oversampling rates. 1088 + * 1089 + * We iterate over the table and choose the product of an oversampling 1090 + * rate and a clock prescaler that gives the lowest integer division 1091 + * result deviation, or if an exact integer divider is found we stop 1092 + * looking for it right away. We do some fixup if the resulting clock 1093 + * divisor required would be out of its unsigned 16-bit integer range. 1094 + * 1095 + * Finally we abuse the supposed fractional part returned to encode the 1096 + * 4-bit value of the oversampling rate and the 9-bit value of the clock 1097 + * prescaler which will end up in the TCR and CPR/CPR2 registers. 1098 + */ 1099 + static unsigned int pci_oxsemi_tornado_get_divisor(struct uart_port *port, 1100 + unsigned int baud, 1101 + unsigned int *frac) 1102 + { 1103 + static u8 p[][2] = { 1104 + { 16, 14, }, { 16, 13, }, { 16, 12, }, { 16, 11, }, 1105 + { 16, 10, }, { 16, 9, }, { 16, 8, }, { 15, 17, }, 1106 + { 15, 16, }, { 15, 15, }, { 15, 14, }, { 15, 13, }, 1107 + { 15, 12, }, { 15, 11, }, { 15, 10, }, { 15, 9, }, 1108 + { 15, 8, }, { 14, 18, }, { 14, 17, }, { 14, 14, }, 1109 + { 14, 13, }, { 14, 12, }, { 14, 11, }, { 14, 10, }, 1110 + { 14, 9, }, { 14, 8, }, { 13, 19, }, { 13, 18, }, 1111 + { 13, 17, }, { 13, 13, }, { 13, 12, }, { 13, 11, }, 1112 + { 13, 10, }, { 13, 9, }, { 13, 8, }, { 12, 19, }, 1113 + { 12, 18, }, { 12, 17, }, { 12, 11, }, { 12, 9, }, 1114 + { 12, 8, }, { 11, 23, }, { 11, 22, }, { 11, 21, }, 1115 + { 11, 20, }, { 11, 19, }, { 11, 18, }, { 11, 17, }, 1116 + { 11, 11, }, { 11, 10, }, { 11, 9, }, { 11, 8, }, 1117 + { 10, 25, }, { 10, 23, }, { 10, 20, }, { 10, 19, }, 1118 + { 10, 17, }, { 10, 10, }, { 10, 9, }, { 10, 8, }, 1119 + { 9, 27, }, { 9, 23, }, { 9, 21, }, { 9, 19, }, 1120 + { 9, 18, }, { 9, 17, }, { 9, 9, }, { 9, 8, }, 1121 + { 8, 31, }, { 8, 29, }, { 8, 23, }, { 8, 19, }, 1122 + { 8, 17, }, { 8, 8, }, { 7, 35, }, { 7, 31, }, 1123 + { 7, 29, }, { 7, 25, }, { 7, 23, }, { 7, 21, }, 1124 + { 7, 19, }, { 7, 17, }, { 7, 15, }, { 7, 14, }, 1125 + { 7, 13, }, { 7, 12, }, { 7, 11, }, { 7, 10, }, 1126 + { 7, 9, }, { 7, 8, }, { 6, 41, }, { 6, 37, }, 1127 + { 6, 31, }, { 6, 29, }, { 6, 23, }, { 6, 19, }, 1128 + { 6, 17, }, { 6, 13, }, { 6, 11, }, { 6, 10, }, 1129 + { 6, 9, }, { 6, 8, }, { 5, 67, }, { 5, 47, }, 1130 + { 5, 43, }, { 5, 41, }, { 5, 37, }, { 5, 31, }, 1131 + { 5, 29, }, { 5, 25, }, { 5, 23, }, { 5, 19, }, 1132 + { 5, 17, }, { 5, 15, }, { 5, 13, }, { 5, 11, }, 1133 + { 5, 10, }, { 5, 9, }, { 5, 8, }, { 4, 61, }, 1134 + { 4, 59, }, { 4, 53, }, { 4, 47, }, { 4, 43, }, 1135 + { 4, 41, }, { 4, 37, }, { 4, 31, }, { 4, 29, }, 1136 + { 4, 23, }, { 4, 19, }, { 4, 17, }, { 4, 13, }, 1137 + { 4, 9, }, { 4, 8, }, 1138 + }; 1139 + /* Scale the quotient for comparison to get the fractional part. */ 1140 + const unsigned int quot_scale = 65536; 1141 + unsigned int sclk = port->uartclk * 2; 1142 + unsigned int sdiv = DIV_ROUND_CLOSEST(sclk, baud); 1143 + unsigned int best_squot; 1144 + unsigned int squot; 1145 + unsigned int quot; 1146 + u16 cpr; 1147 + u8 tcr; 1148 + int i; 1149 + 1150 + /* Old custom speed handling. */ 1151 + if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) { 1152 + unsigned int cust_div = port->custom_divisor; 1153 + 1154 + quot = cust_div & UART_DIV_MAX; 1155 + tcr = (cust_div >> 16) & OXSEMI_TORNADO_TCR_MASK; 1156 + cpr = (cust_div >> 20) & OXSEMI_TORNADO_CPR_MASK; 1157 + if (cpr < OXSEMI_TORNADO_CPR_MIN) 1158 + cpr = OXSEMI_TORNADO_CPR_DEF; 1159 + } else { 1160 + best_squot = quot_scale; 1161 + for (i = 0; i < ARRAY_SIZE(p); i++) { 1162 + unsigned int spre; 1163 + unsigned int srem; 1164 + u8 cp; 1165 + u8 tc; 1166 + 1167 + tc = p[i][0]; 1168 + cp = p[i][1]; 1169 + spre = tc * cp; 1170 + 1171 + srem = sdiv % spre; 1172 + if (srem > spre / 2) 1173 + srem = spre - srem; 1174 + squot = DIV_ROUND_CLOSEST(srem * quot_scale, spre); 1175 + 1176 + if (srem == 0) { 1177 + tcr = tc; 1178 + cpr = cp; 1179 + quot = sdiv / spre; 1180 + break; 1181 + } else if (squot < best_squot) { 1182 + best_squot = squot; 1183 + tcr = tc; 1184 + cpr = cp; 1185 + quot = DIV_ROUND_CLOSEST(sdiv, spre); 1186 + } 1187 + } 1188 + while (tcr <= (OXSEMI_TORNADO_TCR_MASK + 1) >> 1 && 1189 + quot % 2 == 0) { 1190 + quot >>= 1; 1191 + tcr <<= 1; 1192 + } 1193 + while (quot > UART_DIV_MAX) { 1194 + if (tcr <= (OXSEMI_TORNADO_TCR_MASK + 1) >> 1) { 1195 + quot >>= 1; 1196 + tcr <<= 1; 1197 + } else if (cpr <= OXSEMI_TORNADO_CPR_MASK >> 1) { 1198 + quot >>= 1; 1199 + cpr <<= 1; 1200 + } else { 1201 + quot = quot * cpr / OXSEMI_TORNADO_CPR_MASK; 1202 + cpr = OXSEMI_TORNADO_CPR_MASK; 1203 + } 1204 + } 1205 + } 1206 + 1207 + *frac = (cpr << 8) | (tcr & OXSEMI_TORNADO_TCR_MASK); 1208 + return quot; 1209 + } 1210 + 1211 + /* 1212 + * Set the oversampling rate in the transmitter clock cycle register (TCR), 1213 + * the clock prescaler in the clock prescaler register (CPR and CPR2), and 1214 + * the clock divisor in the divisor latch (DLL and DLM). Note that for 1215 + * backwards compatibility any write to CPR clears CPR2 and therefore CPR 1216 + * has to be written first, followed by CPR2, which occupies the location 1217 + * of CKS used with earlier UART designs. 1218 + */ 1219 + static void pci_oxsemi_tornado_set_divisor(struct uart_port *port, 1220 + unsigned int baud, 1221 + unsigned int quot, 1222 + unsigned int quot_frac) 1223 + { 1224 + struct uart_8250_port *up = up_to_u8250p(port); 1225 + u8 cpr2 = quot_frac >> 16; 1226 + u8 cpr = quot_frac >> 8; 1227 + u8 tcr = quot_frac; 1228 + 1229 + serial_icr_write(up, UART_TCR, tcr); 1230 + serial_icr_write(up, UART_CPR, cpr); 1231 + serial_icr_write(up, UART_CKS, cpr2); 1232 + serial8250_do_set_divisor(port, baud, quot, 0); 1233 + } 1234 + 1235 + /* 1236 + * For Tornado devices we force MCR[7] set for the Divide-by-M N/8 baud rate 1237 + * generator prescaler (CPR and CPR2). Otherwise no prescaler would be used. 1238 + */ 1239 + static void pci_oxsemi_tornado_set_mctrl(struct uart_port *port, 1240 + unsigned int mctrl) 1241 + { 1242 + struct uart_8250_port *up = up_to_u8250p(port); 1243 + 1244 + up->mcr |= UART_MCR_CLKSEL; 1245 + serial8250_do_set_mctrl(port, mctrl); 1246 + } 1247 + 1248 + static int pci_oxsemi_tornado_setup(struct serial_private *priv, 1249 + const struct pciserial_board *board, 1250 + struct uart_8250_port *up, int idx) 1251 + { 1252 + struct pci_dev *dev = priv->dev; 1253 + 1254 + if (pci_oxsemi_tornado_p(dev)) { 1255 + up->port.get_divisor = pci_oxsemi_tornado_get_divisor; 1256 + up->port.set_divisor = pci_oxsemi_tornado_set_divisor; 1257 + up->port.set_mctrl = pci_oxsemi_tornado_set_mctrl; 1258 + } 1259 + 1260 + return pci_default_setup(priv, board, up, idx); 1043 1261 } 1044 1262 1045 1263 static int pci_asix_setup(struct serial_private *priv, ··· 2436 2244 .device = PCI_ANY_ID, 2437 2245 .subvendor = PCI_ANY_ID, 2438 2246 .subdevice = PCI_ANY_ID, 2439 - .init = pci_endrun_init, 2247 + .init = pci_oxsemi_tornado_init, 2440 2248 .setup = pci_default_setup, 2441 2249 }, 2442 2250 /* ··· 2448 2256 .subvendor = PCI_ANY_ID, 2449 2257 .subdevice = PCI_ANY_ID, 2450 2258 .init = pci_oxsemi_tornado_init, 2451 - .setup = pci_default_setup, 2259 + .setup = pci_oxsemi_tornado_setup, 2452 2260 }, 2453 2261 { 2454 2262 .vendor = PCI_VENDOR_ID_MAINPINE, ··· 2456 2264 .subvendor = PCI_ANY_ID, 2457 2265 .subdevice = PCI_ANY_ID, 2458 2266 .init = pci_oxsemi_tornado_init, 2459 - .setup = pci_default_setup, 2267 + .setup = pci_oxsemi_tornado_setup, 2460 2268 }, 2461 2269 { 2462 2270 .vendor = PCI_VENDOR_ID_DIGI, ··· 2464 2272 .subvendor = PCI_SUBVENDOR_ID_IBM, 2465 2273 .subdevice = PCI_ANY_ID, 2466 2274 .init = pci_oxsemi_tornado_init, 2467 - .setup = pci_default_setup, 2275 + .setup = pci_oxsemi_tornado_setup, 2468 2276 }, 2469 2277 { 2470 2278 .vendor = PCI_VENDOR_ID_INTEL, ··· 2781 2589 pbn_b0_2_1843200, 2782 2590 pbn_b0_4_1843200, 2783 2591 2784 - pbn_b0_1_3906250, 2592 + pbn_b0_1_15625000, 2785 2593 2786 2594 pbn_b0_bt_1_115200, 2787 2595 pbn_b0_bt_2_115200, ··· 2859 2667 pbn_panacom2, 2860 2668 pbn_panacom4, 2861 2669 pbn_plx_romulus, 2862 - pbn_endrun_2_3906250, 2863 2670 pbn_oxsemi, 2864 - pbn_oxsemi_1_3906250, 2865 - pbn_oxsemi_2_3906250, 2866 - pbn_oxsemi_4_3906250, 2867 - pbn_oxsemi_8_3906250, 2671 + pbn_oxsemi_1_15625000, 2672 + pbn_oxsemi_2_15625000, 2673 + pbn_oxsemi_4_15625000, 2674 + pbn_oxsemi_8_15625000, 2868 2675 pbn_intel_i960, 2869 2676 pbn_sgi_ioc3, 2870 2677 pbn_computone_4, ··· 3006 2815 .uart_offset = 8, 3007 2816 }, 3008 2817 3009 - [pbn_b0_1_3906250] = { 2818 + [pbn_b0_1_15625000] = { 3010 2819 .flags = FL_BASE0, 3011 2820 .num_ports = 1, 3012 - .base_baud = 3906250, 2821 + .base_baud = 15625000, 3013 2822 .uart_offset = 8, 3014 2823 }, 3015 2824 ··· 3381 3190 }, 3382 3191 3383 3192 /* 3384 - * EndRun Technologies 3385 - * Uses the size of PCI Base region 0 to 3386 - * signal now many ports are available 3387 - * 2 port 952 Uart support 3388 - */ 3389 - [pbn_endrun_2_3906250] = { 3390 - .flags = FL_BASE0, 3391 - .num_ports = 2, 3392 - .base_baud = 3906250, 3393 - .uart_offset = 0x200, 3394 - .first_offset = 0x1000, 3395 - }, 3396 - 3397 - /* 3398 3193 * This board uses the size of PCI Base region 0 to 3399 3194 * signal now many ports are available 3400 3195 */ ··· 3390 3213 .base_baud = 115200, 3391 3214 .uart_offset = 8, 3392 3215 }, 3393 - [pbn_oxsemi_1_3906250] = { 3216 + [pbn_oxsemi_1_15625000] = { 3394 3217 .flags = FL_BASE0, 3395 3218 .num_ports = 1, 3396 - .base_baud = 3906250, 3219 + .base_baud = 15625000, 3397 3220 .uart_offset = 0x200, 3398 3221 .first_offset = 0x1000, 3399 3222 }, 3400 - [pbn_oxsemi_2_3906250] = { 3223 + [pbn_oxsemi_2_15625000] = { 3401 3224 .flags = FL_BASE0, 3402 3225 .num_ports = 2, 3403 - .base_baud = 3906250, 3226 + .base_baud = 15625000, 3404 3227 .uart_offset = 0x200, 3405 3228 .first_offset = 0x1000, 3406 3229 }, 3407 - [pbn_oxsemi_4_3906250] = { 3230 + [pbn_oxsemi_4_15625000] = { 3408 3231 .flags = FL_BASE0, 3409 3232 .num_ports = 4, 3410 - .base_baud = 3906250, 3233 + .base_baud = 15625000, 3411 3234 .uart_offset = 0x200, 3412 3235 .first_offset = 0x1000, 3413 3236 }, 3414 - [pbn_oxsemi_8_3906250] = { 3237 + [pbn_oxsemi_8_15625000] = { 3415 3238 .flags = FL_BASE0, 3416 3239 .num_ports = 8, 3417 - .base_baud = 3906250, 3240 + .base_baud = 15625000, 3418 3241 .uart_offset = 0x200, 3419 3242 .first_offset = 0x1000, 3420 3243 }, ··· 3695 3518 }, 3696 3519 }; 3697 3520 3521 + #define REPORT_CONFIG(option) \ 3522 + (IS_ENABLED(CONFIG_##option) ? 0 : (kernel_ulong_t)&#option) 3523 + #define REPORT_8250_CONFIG(option) \ 3524 + (IS_ENABLED(CONFIG_SERIAL_8250_##option) ? \ 3525 + 0 : (kernel_ulong_t)&"SERIAL_8250_"#option) 3526 + 3698 3527 static const struct pci_device_id blacklist[] = { 3699 3528 /* softmodems */ 3700 3529 { PCI_VDEVICE(AL, 0x5457), }, /* ALi Corporation M5457 AC'97 Modem */ ··· 3708 3525 { PCI_DEVICE(0x1543, 0x3052), }, /* Si3052-based modem, default IDs */ 3709 3526 3710 3527 /* multi-io cards handled by parport_serial */ 3711 - { PCI_DEVICE(0x4348, 0x7053), }, /* WCH CH353 2S1P */ 3712 - { PCI_DEVICE(0x4348, 0x5053), }, /* WCH CH353 1S1P */ 3713 - { PCI_DEVICE(0x1c00, 0x3250), }, /* WCH CH382 2S1P */ 3528 + /* WCH CH353 2S1P */ 3529 + { PCI_DEVICE(0x4348, 0x7053), 0, 0, REPORT_CONFIG(PARPORT_SERIAL), }, 3530 + /* WCH CH353 1S1P */ 3531 + { PCI_DEVICE(0x4348, 0x5053), 0, 0, REPORT_CONFIG(PARPORT_SERIAL), }, 3532 + /* WCH CH382 2S1P */ 3533 + { PCI_DEVICE(0x1c00, 0x3250), 0, 0, REPORT_CONFIG(PARPORT_SERIAL), }, 3714 3534 3715 3535 /* Intel platforms with MID UART */ 3716 - { PCI_VDEVICE(INTEL, 0x081b), }, 3717 - { PCI_VDEVICE(INTEL, 0x081c), }, 3718 - { PCI_VDEVICE(INTEL, 0x081d), }, 3719 - { PCI_VDEVICE(INTEL, 0x1191), }, 3720 - { PCI_VDEVICE(INTEL, 0x18d8), }, 3721 - { PCI_VDEVICE(INTEL, 0x19d8), }, 3536 + { PCI_VDEVICE(INTEL, 0x081b), REPORT_8250_CONFIG(MID), }, 3537 + { PCI_VDEVICE(INTEL, 0x081c), REPORT_8250_CONFIG(MID), }, 3538 + { PCI_VDEVICE(INTEL, 0x081d), REPORT_8250_CONFIG(MID), }, 3539 + { PCI_VDEVICE(INTEL, 0x1191), REPORT_8250_CONFIG(MID), }, 3540 + { PCI_VDEVICE(INTEL, 0x18d8), REPORT_8250_CONFIG(MID), }, 3541 + { PCI_VDEVICE(INTEL, 0x19d8), REPORT_8250_CONFIG(MID), }, 3722 3542 3723 3543 /* Intel platforms with DesignWare UART */ 3724 - { PCI_VDEVICE(INTEL, 0x0936), }, 3725 - { PCI_VDEVICE(INTEL, 0x0f0a), }, 3726 - { PCI_VDEVICE(INTEL, 0x0f0c), }, 3727 - { PCI_VDEVICE(INTEL, 0x228a), }, 3728 - { PCI_VDEVICE(INTEL, 0x228c), }, 3729 - { PCI_VDEVICE(INTEL, 0x4b96), }, 3730 - { PCI_VDEVICE(INTEL, 0x4b97), }, 3731 - { PCI_VDEVICE(INTEL, 0x4b98), }, 3732 - { PCI_VDEVICE(INTEL, 0x4b99), }, 3733 - { PCI_VDEVICE(INTEL, 0x4b9a), }, 3734 - { PCI_VDEVICE(INTEL, 0x4b9b), }, 3735 - { PCI_VDEVICE(INTEL, 0x9ce3), }, 3736 - { PCI_VDEVICE(INTEL, 0x9ce4), }, 3544 + { PCI_VDEVICE(INTEL, 0x0936), REPORT_8250_CONFIG(LPSS), }, 3545 + { PCI_VDEVICE(INTEL, 0x0f0a), REPORT_8250_CONFIG(LPSS), }, 3546 + { PCI_VDEVICE(INTEL, 0x0f0c), REPORT_8250_CONFIG(LPSS), }, 3547 + { PCI_VDEVICE(INTEL, 0x228a), REPORT_8250_CONFIG(LPSS), }, 3548 + { PCI_VDEVICE(INTEL, 0x228c), REPORT_8250_CONFIG(LPSS), }, 3549 + { PCI_VDEVICE(INTEL, 0x4b96), REPORT_8250_CONFIG(LPSS), }, 3550 + { PCI_VDEVICE(INTEL, 0x4b97), REPORT_8250_CONFIG(LPSS), }, 3551 + { PCI_VDEVICE(INTEL, 0x4b98), REPORT_8250_CONFIG(LPSS), }, 3552 + { PCI_VDEVICE(INTEL, 0x4b99), REPORT_8250_CONFIG(LPSS), }, 3553 + { PCI_VDEVICE(INTEL, 0x4b9a), REPORT_8250_CONFIG(LPSS), }, 3554 + { PCI_VDEVICE(INTEL, 0x4b9b), REPORT_8250_CONFIG(LPSS), }, 3555 + { PCI_VDEVICE(INTEL, 0x9ce3), REPORT_8250_CONFIG(LPSS), }, 3556 + { PCI_VDEVICE(INTEL, 0x9ce4), REPORT_8250_CONFIG(LPSS), }, 3737 3557 3738 3558 /* Exar devices */ 3739 - { PCI_VDEVICE(EXAR, PCI_ANY_ID), }, 3740 - { PCI_VDEVICE(COMMTECH, PCI_ANY_ID), }, 3559 + { PCI_VDEVICE(EXAR, PCI_ANY_ID), REPORT_8250_CONFIG(EXAR), }, 3560 + { PCI_VDEVICE(COMMTECH, PCI_ANY_ID), REPORT_8250_CONFIG(EXAR), }, 3741 3561 3742 3562 /* Pericom devices */ 3743 - { PCI_VDEVICE(PERICOM, PCI_ANY_ID), }, 3744 - { PCI_VDEVICE(ACCESSIO, PCI_ANY_ID), }, 3563 + { PCI_VDEVICE(PERICOM, PCI_ANY_ID), REPORT_8250_CONFIG(PERICOM), }, 3564 + { PCI_VDEVICE(ACCESSIO, PCI_ANY_ID), REPORT_8250_CONFIG(PERICOM), }, 3745 3565 3746 3566 /* End of the black list */ 3747 3567 { } ··· 4026 3840 board = &pci_boards[ent->driver_data]; 4027 3841 4028 3842 exclude = pci_match_id(blacklist, dev); 4029 - if (exclude) 3843 + if (exclude) { 3844 + if (exclude->driver_data) 3845 + pci_warn(dev, "ignoring port, enable %s to handle\n", 3846 + (const char *)exclude->driver_data); 4030 3847 return -ENODEV; 3848 + } 4031 3849 4032 3850 rc = pcim_enable_device(dev); 4033 3851 pci_save_state(dev); ··· 4300 4110 0x10b5, 0x106a, 0, 0, 4301 4111 pbn_plx_romulus }, 4302 4112 /* 4303 - * EndRun Technologies. PCI express device range. 4304 - * EndRun PTP/1588 has 2 Native UARTs. 4305 - */ 4306 - { PCI_VENDOR_ID_ENDRUN, PCI_DEVICE_ID_ENDRUN_1588, 4307 - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4308 - pbn_endrun_2_3906250 }, 4309 - /* 4310 4113 * Quatech cards. These actually have configurable clocks but for 4311 4114 * now we just use the default. 4312 4115 * ··· 4408 4225 */ 4409 4226 { PCI_VENDOR_ID_OXSEMI, 0xc101, /* OXPCIe952 1 Legacy UART */ 4410 4227 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4411 - pbn_b0_1_3906250 }, 4228 + pbn_b0_1_15625000 }, 4412 4229 { PCI_VENDOR_ID_OXSEMI, 0xc105, /* OXPCIe952 1 Legacy UART */ 4413 4230 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4414 - pbn_b0_1_3906250 }, 4231 + pbn_b0_1_15625000 }, 4415 4232 { PCI_VENDOR_ID_OXSEMI, 0xc11b, /* OXPCIe952 1 Native UART */ 4416 4233 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4417 - pbn_oxsemi_1_3906250 }, 4234 + pbn_oxsemi_1_15625000 }, 4418 4235 { PCI_VENDOR_ID_OXSEMI, 0xc11f, /* OXPCIe952 1 Native UART */ 4419 4236 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4420 - pbn_oxsemi_1_3906250 }, 4237 + pbn_oxsemi_1_15625000 }, 4421 4238 { PCI_VENDOR_ID_OXSEMI, 0xc120, /* OXPCIe952 1 Legacy UART */ 4422 4239 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4423 - pbn_b0_1_3906250 }, 4240 + pbn_b0_1_15625000 }, 4424 4241 { PCI_VENDOR_ID_OXSEMI, 0xc124, /* OXPCIe952 1 Legacy UART */ 4425 4242 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4426 - pbn_b0_1_3906250 }, 4243 + pbn_b0_1_15625000 }, 4427 4244 { PCI_VENDOR_ID_OXSEMI, 0xc138, /* OXPCIe952 1 Native UART */ 4428 4245 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4429 - pbn_oxsemi_1_3906250 }, 4246 + pbn_oxsemi_1_15625000 }, 4430 4247 { PCI_VENDOR_ID_OXSEMI, 0xc13d, /* OXPCIe952 1 Native UART */ 4431 4248 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4432 - pbn_oxsemi_1_3906250 }, 4249 + pbn_oxsemi_1_15625000 }, 4433 4250 { PCI_VENDOR_ID_OXSEMI, 0xc140, /* OXPCIe952 1 Legacy UART */ 4434 4251 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4435 - pbn_b0_1_3906250 }, 4252 + pbn_b0_1_15625000 }, 4436 4253 { PCI_VENDOR_ID_OXSEMI, 0xc141, /* OXPCIe952 1 Legacy UART */ 4437 4254 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4438 - pbn_b0_1_3906250 }, 4255 + pbn_b0_1_15625000 }, 4439 4256 { PCI_VENDOR_ID_OXSEMI, 0xc144, /* OXPCIe952 1 Legacy UART */ 4440 4257 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4441 - pbn_b0_1_3906250 }, 4258 + pbn_b0_1_15625000 }, 4442 4259 { PCI_VENDOR_ID_OXSEMI, 0xc145, /* OXPCIe952 1 Legacy UART */ 4443 4260 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4444 - pbn_b0_1_3906250 }, 4261 + pbn_b0_1_15625000 }, 4445 4262 { PCI_VENDOR_ID_OXSEMI, 0xc158, /* OXPCIe952 2 Native UART */ 4446 4263 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4447 - pbn_oxsemi_2_3906250 }, 4264 + pbn_oxsemi_2_15625000 }, 4448 4265 { PCI_VENDOR_ID_OXSEMI, 0xc15d, /* OXPCIe952 2 Native UART */ 4449 4266 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4450 - pbn_oxsemi_2_3906250 }, 4267 + pbn_oxsemi_2_15625000 }, 4451 4268 { PCI_VENDOR_ID_OXSEMI, 0xc208, /* OXPCIe954 4 Native UART */ 4452 4269 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4453 - pbn_oxsemi_4_3906250 }, 4270 + pbn_oxsemi_4_15625000 }, 4454 4271 { PCI_VENDOR_ID_OXSEMI, 0xc20d, /* OXPCIe954 4 Native UART */ 4455 4272 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4456 - pbn_oxsemi_4_3906250 }, 4273 + pbn_oxsemi_4_15625000 }, 4457 4274 { PCI_VENDOR_ID_OXSEMI, 0xc308, /* OXPCIe958 8 Native UART */ 4458 4275 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4459 - pbn_oxsemi_8_3906250 }, 4276 + pbn_oxsemi_8_15625000 }, 4460 4277 { PCI_VENDOR_ID_OXSEMI, 0xc30d, /* OXPCIe958 8 Native UART */ 4461 4278 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4462 - pbn_oxsemi_8_3906250 }, 4279 + pbn_oxsemi_8_15625000 }, 4463 4280 { PCI_VENDOR_ID_OXSEMI, 0xc40b, /* OXPCIe200 1 Native UART */ 4464 4281 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4465 - pbn_oxsemi_1_3906250 }, 4282 + pbn_oxsemi_1_15625000 }, 4466 4283 { PCI_VENDOR_ID_OXSEMI, 0xc40f, /* OXPCIe200 1 Native UART */ 4467 4284 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4468 - pbn_oxsemi_1_3906250 }, 4285 + pbn_oxsemi_1_15625000 }, 4469 4286 { PCI_VENDOR_ID_OXSEMI, 0xc41b, /* OXPCIe200 1 Native UART */ 4470 4287 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4471 - pbn_oxsemi_1_3906250 }, 4288 + pbn_oxsemi_1_15625000 }, 4472 4289 { PCI_VENDOR_ID_OXSEMI, 0xc41f, /* OXPCIe200 1 Native UART */ 4473 4290 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4474 - pbn_oxsemi_1_3906250 }, 4291 + pbn_oxsemi_1_15625000 }, 4475 4292 { PCI_VENDOR_ID_OXSEMI, 0xc42b, /* OXPCIe200 1 Native UART */ 4476 4293 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4477 - pbn_oxsemi_1_3906250 }, 4294 + pbn_oxsemi_1_15625000 }, 4478 4295 { PCI_VENDOR_ID_OXSEMI, 0xc42f, /* OXPCIe200 1 Native UART */ 4479 4296 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4480 - pbn_oxsemi_1_3906250 }, 4297 + pbn_oxsemi_1_15625000 }, 4481 4298 { PCI_VENDOR_ID_OXSEMI, 0xc43b, /* OXPCIe200 1 Native UART */ 4482 4299 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4483 - pbn_oxsemi_1_3906250 }, 4300 + pbn_oxsemi_1_15625000 }, 4484 4301 { PCI_VENDOR_ID_OXSEMI, 0xc43f, /* OXPCIe200 1 Native UART */ 4485 4302 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4486 - pbn_oxsemi_1_3906250 }, 4303 + pbn_oxsemi_1_15625000 }, 4487 4304 { PCI_VENDOR_ID_OXSEMI, 0xc44b, /* OXPCIe200 1 Native UART */ 4488 4305 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4489 - pbn_oxsemi_1_3906250 }, 4306 + pbn_oxsemi_1_15625000 }, 4490 4307 { PCI_VENDOR_ID_OXSEMI, 0xc44f, /* OXPCIe200 1 Native UART */ 4491 4308 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4492 - pbn_oxsemi_1_3906250 }, 4309 + pbn_oxsemi_1_15625000 }, 4493 4310 { PCI_VENDOR_ID_OXSEMI, 0xc45b, /* OXPCIe200 1 Native UART */ 4494 4311 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4495 - pbn_oxsemi_1_3906250 }, 4312 + pbn_oxsemi_1_15625000 }, 4496 4313 { PCI_VENDOR_ID_OXSEMI, 0xc45f, /* OXPCIe200 1 Native UART */ 4497 4314 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4498 - pbn_oxsemi_1_3906250 }, 4315 + pbn_oxsemi_1_15625000 }, 4499 4316 { PCI_VENDOR_ID_OXSEMI, 0xc46b, /* OXPCIe200 1 Native UART */ 4500 4317 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4501 - pbn_oxsemi_1_3906250 }, 4318 + pbn_oxsemi_1_15625000 }, 4502 4319 { PCI_VENDOR_ID_OXSEMI, 0xc46f, /* OXPCIe200 1 Native UART */ 4503 4320 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4504 - pbn_oxsemi_1_3906250 }, 4321 + pbn_oxsemi_1_15625000 }, 4505 4322 { PCI_VENDOR_ID_OXSEMI, 0xc47b, /* OXPCIe200 1 Native UART */ 4506 4323 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4507 - pbn_oxsemi_1_3906250 }, 4324 + pbn_oxsemi_1_15625000 }, 4508 4325 { PCI_VENDOR_ID_OXSEMI, 0xc47f, /* OXPCIe200 1 Native UART */ 4509 4326 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4510 - pbn_oxsemi_1_3906250 }, 4327 + pbn_oxsemi_1_15625000 }, 4511 4328 { PCI_VENDOR_ID_OXSEMI, 0xc48b, /* OXPCIe200 1 Native UART */ 4512 4329 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4513 - pbn_oxsemi_1_3906250 }, 4330 + pbn_oxsemi_1_15625000 }, 4514 4331 { PCI_VENDOR_ID_OXSEMI, 0xc48f, /* OXPCIe200 1 Native UART */ 4515 4332 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4516 - pbn_oxsemi_1_3906250 }, 4333 + pbn_oxsemi_1_15625000 }, 4517 4334 { PCI_VENDOR_ID_OXSEMI, 0xc49b, /* OXPCIe200 1 Native UART */ 4518 4335 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4519 - pbn_oxsemi_1_3906250 }, 4336 + pbn_oxsemi_1_15625000 }, 4520 4337 { PCI_VENDOR_ID_OXSEMI, 0xc49f, /* OXPCIe200 1 Native UART */ 4521 4338 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4522 - pbn_oxsemi_1_3906250 }, 4339 + pbn_oxsemi_1_15625000 }, 4523 4340 { PCI_VENDOR_ID_OXSEMI, 0xc4ab, /* OXPCIe200 1 Native UART */ 4524 4341 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4525 - pbn_oxsemi_1_3906250 }, 4342 + pbn_oxsemi_1_15625000 }, 4526 4343 { PCI_VENDOR_ID_OXSEMI, 0xc4af, /* OXPCIe200 1 Native UART */ 4527 4344 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4528 - pbn_oxsemi_1_3906250 }, 4345 + pbn_oxsemi_1_15625000 }, 4529 4346 { PCI_VENDOR_ID_OXSEMI, 0xc4bb, /* OXPCIe200 1 Native UART */ 4530 4347 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4531 - pbn_oxsemi_1_3906250 }, 4348 + pbn_oxsemi_1_15625000 }, 4532 4349 { PCI_VENDOR_ID_OXSEMI, 0xc4bf, /* OXPCIe200 1 Native UART */ 4533 4350 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4534 - pbn_oxsemi_1_3906250 }, 4351 + pbn_oxsemi_1_15625000 }, 4535 4352 { PCI_VENDOR_ID_OXSEMI, 0xc4cb, /* OXPCIe200 1 Native UART */ 4536 4353 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4537 - pbn_oxsemi_1_3906250 }, 4354 + pbn_oxsemi_1_15625000 }, 4538 4355 { PCI_VENDOR_ID_OXSEMI, 0xc4cf, /* OXPCIe200 1 Native UART */ 4539 4356 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4540 - pbn_oxsemi_1_3906250 }, 4357 + pbn_oxsemi_1_15625000 }, 4541 4358 /* 4542 4359 * Mainpine Inc. IQ Express "Rev3" utilizing OxSemi Tornado 4543 4360 */ 4544 4361 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 1 Port V.34 Super-G3 Fax */ 4545 4362 PCI_VENDOR_ID_MAINPINE, 0x4001, 0, 0, 4546 - pbn_oxsemi_1_3906250 }, 4363 + pbn_oxsemi_1_15625000 }, 4547 4364 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 2 Port V.34 Super-G3 Fax */ 4548 4365 PCI_VENDOR_ID_MAINPINE, 0x4002, 0, 0, 4549 - pbn_oxsemi_2_3906250 }, 4366 + pbn_oxsemi_2_15625000 }, 4550 4367 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 4 Port V.34 Super-G3 Fax */ 4551 4368 PCI_VENDOR_ID_MAINPINE, 0x4004, 0, 0, 4552 - pbn_oxsemi_4_3906250 }, 4369 + pbn_oxsemi_4_15625000 }, 4553 4370 { PCI_VENDOR_ID_MAINPINE, 0x4000, /* IQ Express 8 Port V.34 Super-G3 Fax */ 4554 4371 PCI_VENDOR_ID_MAINPINE, 0x4008, 0, 0, 4555 - pbn_oxsemi_8_3906250 }, 4372 + pbn_oxsemi_8_15625000 }, 4556 4373 4557 4374 /* 4558 4375 * Digi/IBM PCIe 2-port Async EIA-232 Adapter utilizing OxSemi Tornado 4559 4376 */ 4560 4377 { PCI_VENDOR_ID_DIGI, PCIE_DEVICE_ID_NEO_2_OX_IBM, 4561 4378 PCI_SUBVENDOR_ID_IBM, PCI_ANY_ID, 0, 0, 4562 - pbn_oxsemi_2_3906250 }, 4379 + pbn_oxsemi_2_15625000 }, 4380 + /* 4381 + * EndRun Technologies. PCI express device range. 4382 + * EndRun PTP/1588 has 2 Native UARTs utilizing OxSemi 952. 4383 + */ 4384 + { PCI_VENDOR_ID_ENDRUN, PCI_DEVICE_ID_ENDRUN_1588, 4385 + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4386 + pbn_oxsemi_2_15625000 }, 4563 4387 4564 4388 /* 4565 4389 * SBS Technologies, Inc. P-Octal and PMC-OCTPRO cards,
+98 -42
drivers/tty/serial/8250/8250_port.c
··· 263 263 .tx_loadsz = 63, 264 264 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10 | 265 265 UART_FCR7_64BYTE, 266 - .flags = UART_CAP_FIFO, 266 + .flags = UART_CAP_FIFO | UART_CAP_NOTEMT, 267 267 }, 268 268 [PORT_RT2880] = { 269 269 .name = "Palmchip BK-3103", ··· 535 535 default: 536 536 p->serial_out(p, offset, value); 537 537 } 538 - } 539 - 540 - /* 541 - * For the 16C950 542 - */ 543 - static void serial_icr_write(struct uart_8250_port *up, int offset, int value) 544 - { 545 - serial_out(up, UART_SCR, offset); 546 - serial_out(up, UART_ICR, value); 547 - } 548 - 549 - static unsigned int serial_icr_read(struct uart_8250_port *up, int offset) 550 - { 551 - unsigned int value; 552 - 553 - serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD); 554 - serial_out(up, UART_SCR, offset); 555 - value = serial_in(up, UART_ICR); 556 - serial_icr_write(up, UART_ACR, up->acr); 557 - 558 - return value; 559 538 } 560 539 561 540 /* ··· 1483 1504 hrtimer_start(hrt, ms_to_ktime(msec), HRTIMER_MODE_REL); 1484 1505 } 1485 1506 1486 - static void __stop_tx_rs485(struct uart_8250_port *p) 1507 + static void __stop_tx_rs485(struct uart_8250_port *p, u64 stop_delay) 1487 1508 { 1488 1509 struct uart_8250_em485 *em485 = p->em485; 1510 + 1511 + stop_delay += (u64)p->port.rs485.delay_rts_after_send * NSEC_PER_MSEC; 1489 1512 1490 1513 /* 1491 1514 * rs485_stop_tx() is going to set RTS according to config 1492 1515 * AND flush RX FIFO if required. 1493 1516 */ 1494 - if (p->port.rs485.delay_rts_after_send > 0) { 1517 + if (stop_delay > 0) { 1495 1518 em485->active_timer = &em485->stop_tx_timer; 1496 - start_hrtimer_ms(&em485->stop_tx_timer, 1497 - p->port.rs485.delay_rts_after_send); 1519 + hrtimer_start(&em485->stop_tx_timer, ns_to_ktime(stop_delay), HRTIMER_MODE_REL); 1498 1520 } else { 1499 1521 p->rs485_stop_tx(p); 1500 1522 em485->active_timer = NULL; ··· 1515 1535 1516 1536 if (em485) { 1517 1537 unsigned char lsr = serial_in(p, UART_LSR); 1538 + u64 stop_delay = 0; 1539 + 1540 + if (!(lsr & UART_LSR_THRE)) 1541 + return; 1518 1542 /* 1519 1543 * To provide required timeing and allow FIFO transfer, 1520 1544 * __stop_tx_rs485() must be called only when both FIFO and 1521 - * shift register are empty. It is for device driver to enable 1522 - * interrupt on TEMT. 1545 + * shift register are empty. The device driver should either 1546 + * enable interrupt on TEMT or set UART_CAP_NOTEMT that will 1547 + * enlarge stop_tx_timer by the tx time of one frame to cover 1548 + * for emptying of the shift register. 1523 1549 */ 1524 - if ((lsr & BOTH_EMPTY) != BOTH_EMPTY) 1525 - return; 1550 + if (!(lsr & UART_LSR_TEMT)) { 1551 + if (!(p->capabilities & UART_CAP_NOTEMT)) 1552 + return; 1553 + /* 1554 + * RTS might get deasserted too early with the normal 1555 + * frame timing formula. It seems to suggest THRE might 1556 + * get asserted already during tx of the stop bit 1557 + * rather than after it is fully sent. 1558 + * Roughly estimate 1 extra bit here with / 7. 1559 + */ 1560 + stop_delay = p->port.frame_time + DIV_ROUND_UP(p->port.frame_time, 7); 1561 + } 1526 1562 1527 - __stop_tx_rs485(p); 1563 + __stop_tx_rs485(p, stop_delay); 1528 1564 } 1529 1565 __do_stop_tx(p); 1530 1566 } ··· 1944 1948 status = serial8250_rx_chars(up, status); 1945 1949 } 1946 1950 serial8250_modem_status(up); 1947 - if ((!up->dma || up->dma->tx_err) && (status & UART_LSR_THRE) && 1948 - (up->ier & UART_IER_THRI)) 1949 - serial8250_tx_chars(up); 1951 + if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) { 1952 + if (!up->dma || up->dma->tx_err) 1953 + serial8250_tx_chars(up); 1954 + else 1955 + __stop_tx(up); 1956 + } 1950 1957 1951 1958 uart_unlock_and_check_sysrq_irqrestore(port, flags); 1952 1959 ··· 2076 2077 serial8250_rpm_put(up); 2077 2078 } 2078 2079 2079 - /* 2080 - * Wait for transmitter & holding register to empty 2081 - */ 2082 - static void wait_for_xmitr(struct uart_8250_port *up, int bits) 2080 + static void wait_for_lsr(struct uart_8250_port *up, int bits) 2083 2081 { 2084 2082 unsigned int status, tmout = 10000; 2085 2083 ··· 2093 2097 udelay(1); 2094 2098 touch_nmi_watchdog(); 2095 2099 } 2100 + } 2101 + 2102 + /* 2103 + * Wait for transmitter & holding register to empty 2104 + */ 2105 + static void wait_for_xmitr(struct uart_8250_port *up, int bits) 2106 + { 2107 + unsigned int tmout; 2108 + 2109 + wait_for_lsr(up, bits); 2096 2110 2097 2111 /* Wait up to 1s for flow control if necessary */ 2098 2112 if (up->port.flags & UPF_CONS_FLOW) { ··· 2620 2614 } 2621 2615 if (!(c_cflag & PARODD)) 2622 2616 cval |= UART_LCR_EPAR; 2623 - #ifdef CMSPAR 2624 2617 if (c_cflag & CMSPAR) 2625 2618 cval |= UART_LCR_SPAR; 2626 - #endif 2627 2619 2628 2620 return cval; 2629 2621 } ··· 3337 3333 } 3338 3334 3339 3335 /* 3336 + * Print a string to the serial port using the device FIFO 3337 + * 3338 + * It sends fifosize bytes and then waits for the fifo 3339 + * to get empty. 3340 + */ 3341 + static void serial8250_console_fifo_write(struct uart_8250_port *up, 3342 + const char *s, unsigned int count) 3343 + { 3344 + int i; 3345 + const char *end = s + count; 3346 + unsigned int fifosize = up->tx_loadsz; 3347 + bool cr_sent = false; 3348 + 3349 + while (s != end) { 3350 + wait_for_lsr(up, UART_LSR_THRE); 3351 + 3352 + for (i = 0; i < fifosize && s != end; ++i) { 3353 + if (*s == '\n' && !cr_sent) { 3354 + serial_out(up, UART_TX, '\r'); 3355 + cr_sent = true; 3356 + } else { 3357 + serial_out(up, UART_TX, *s++); 3358 + cr_sent = false; 3359 + } 3360 + } 3361 + } 3362 + } 3363 + 3364 + /* 3340 3365 * Print a string to the serial port trying not to disturb 3341 3366 * any possible real use of the port... 3342 3367 * ··· 3380 3347 struct uart_8250_em485 *em485 = up->em485; 3381 3348 struct uart_port *port = &up->port; 3382 3349 unsigned long flags; 3383 - unsigned int ier; 3350 + unsigned int ier, use_fifo; 3384 3351 int locked = 1; 3385 3352 3386 3353 touch_nmi_watchdog(); ··· 3412 3379 mdelay(port->rs485.delay_rts_before_send); 3413 3380 } 3414 3381 3415 - uart_console_write(port, s, count, serial8250_console_putchar); 3382 + use_fifo = (up->capabilities & UART_CAP_FIFO) && 3383 + /* 3384 + * BCM283x requires to check the fifo 3385 + * after each byte. 3386 + */ 3387 + !(up->capabilities & UART_CAP_MINI) && 3388 + /* 3389 + * tx_loadsz contains the transmit fifo size 3390 + */ 3391 + up->tx_loadsz > 1 && 3392 + (up->fcr & UART_FCR_ENABLE_FIFO) && 3393 + port->state && 3394 + test_bit(TTY_PORT_INITIALIZED, &port->state->port.iflags) && 3395 + /* 3396 + * After we put a data in the fifo, the controller will send 3397 + * it regardless of the CTS state. Therefore, only use fifo 3398 + * if we don't use control flow. 3399 + */ 3400 + !(up->port.flags & UPF_CONS_FLOW); 3401 + 3402 + if (likely(use_fifo)) 3403 + serial8250_console_fifo_write(up, s, count); 3404 + else 3405 + uart_console_write(port, s, count, serial8250_console_putchar); 3416 3406 3417 3407 /* 3418 3408 * Finally, wait for transmitter to become empty
-1
drivers/tty/serial/8250/8250_pxa.c
··· 22 22 #include <linux/platform_device.h> 23 23 #include <linux/slab.h> 24 24 #include <linux/clk.h> 25 - #include <linux/pm_runtime.h> 26 25 27 26 #include "8250.h" 28 27
+1 -1
drivers/tty/serial/8250/Kconfig
··· 380 380 config SERIAL_8250_EM 381 381 tristate "Support for Emma Mobile integrated serial port" 382 382 depends on SERIAL_8250 && HAVE_CLK 383 - depends on (ARM && ARCH_RENESAS) || COMPILE_TEST 383 + depends on ARCH_RENESAS || COMPILE_TEST 384 384 help 385 385 Selecting this option will add support for the integrated serial 386 386 port hardware found on the Emma Mobile line of processors.
+5 -4
drivers/tty/serial/Kconfig
··· 782 782 783 783 config SERIAL_CPM 784 784 tristate "CPM SCC/SMC serial port support" 785 - depends on CPM2 || CPM1 785 + depends on CPM2 || CPM1 || (PPC32 && COMPILE_TEST) 786 786 select SERIAL_CORE 787 787 help 788 788 This driver supports the SCC and SMC serial ports on Motorola ··· 806 806 807 807 config SERIAL_PIC32 808 808 tristate "Microchip PIC32 serial support" 809 - depends on MACH_PIC32 809 + depends on MACH_PIC32 || (MIPS && COMPILE_TEST) 810 810 select SERIAL_CORE 811 811 help 812 812 If you have a PIC32, this driver supports the serial ports. ··· 817 817 818 818 config SERIAL_PIC32_CONSOLE 819 819 bool "PIC32 serial console support" 820 - depends on SERIAL_PIC32 820 + depends on SERIAL_PIC32=y 821 821 select SERIAL_CORE_CONSOLE 822 822 help 823 823 If you have a PIC32, this driver supports the putting a console on one ··· 1246 1246 1247 1247 config SERIAL_AR933X 1248 1248 tristate "AR933X serial port support" 1249 - depends on HAVE_CLK && ATH79 1249 + depends on (HAVE_CLK && ATH79) || (MIPS && COMPILE_TEST) 1250 1250 select SERIAL_CORE 1251 1251 select SERIAL_MCTRL_GPIO if GPIOLIB 1252 1252 help ··· 1442 1442 bool "Support for console on STM32" 1443 1443 depends on SERIAL_STM32=y 1444 1444 select SERIAL_CORE_CONSOLE 1445 + select SERIAL_EARLYCON 1445 1446 1446 1447 config SERIAL_MVEBU_UART 1447 1448 bool "Marvell EBU serial port support"
+2 -4
drivers/tty/serial/altera_jtaguart.c
··· 168 168 } 169 169 } 170 170 171 - if (pending == 0) { 172 - pp->imr &= ~ALTERA_JTAGUART_CONTROL_WE_MSK; 173 - writel(pp->imr, port->membase + ALTERA_JTAGUART_CONTROL_REG); 174 - } 171 + if (pending == 0) 172 + altera_jtaguart_stop_tx(port); 175 173 } 176 174 177 175 static irqreturn_t altera_jtaguart_interrupt(int irq, void *data)
+31 -17
drivers/tty/serial/amba-pl011.c
··· 42 42 #include <linux/io.h> 43 43 #include <linux/acpi.h> 44 44 45 - #include "amba-pl011.h" 46 - 47 45 #define UART_NR 14 48 46 49 47 #define SERIAL_AMBA_MAJOR 204 ··· 52 54 53 55 #define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) 54 56 #define UART_DUMMY_DR_RX (1 << 16) 57 + 58 + enum { 59 + REG_DR, 60 + REG_ST_DMAWM, 61 + REG_ST_TIMEOUT, 62 + REG_FR, 63 + REG_LCRH_RX, 64 + REG_LCRH_TX, 65 + REG_IBRD, 66 + REG_FBRD, 67 + REG_CR, 68 + REG_IFLS, 69 + REG_IMSC, 70 + REG_RIS, 71 + REG_MIS, 72 + REG_ICR, 73 + REG_DMACR, 74 + REG_ST_XFCR, 75 + REG_ST_XON1, 76 + REG_ST_XON2, 77 + REG_ST_XOFF1, 78 + REG_ST_XOFF2, 79 + REG_ST_ITCR, 80 + REG_ST_ITIP, 81 + REG_ST_ABCR, 82 + REG_ST_ABIMSC, 83 + 84 + /* The size of the array - must be last */ 85 + REG_ARRAY_SIZE, 86 + }; 55 87 56 88 static u16 pl011_std_offsets[REG_ARRAY_SIZE] = { 57 89 [REG_DR] = UART01x_DR, ··· 2203 2175 struct uart_amba_port *uap = 2204 2176 container_of(port, struct uart_amba_port, port); 2205 2177 2206 - /* pick sane settings if the user hasn't */ 2207 - if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == 2208 - !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { 2209 - rs485->flags |= SER_RS485_RTS_ON_SEND; 2210 - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; 2211 - } 2212 - /* clamp the delays to [0, 100ms] */ 2213 - rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); 2214 - rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); 2215 - memset(rs485->padding, 0, sizeof(rs485->padding)); 2216 - 2217 2178 if (port->rs485.flags & SER_RS485_ENABLED) 2218 2179 pl011_rs485_tx_stop(uap); 2219 2180 2220 - /* Set new configuration */ 2221 - port->rs485 = *rs485; 2222 - 2223 2181 /* Make sure auto RTS is disabled */ 2224 - if (port->rs485.flags & SER_RS485_ENABLED) { 2182 + if (rs485->flags & SER_RS485_ENABLED) { 2225 2183 u32 cr = pl011_read(uap, REG_CR); 2226 2184 2227 2185 cr &= ~UART011_CR_RTSEN;
-35
drivers/tty/serial/amba-pl011.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef AMBA_PL011_H 3 - #define AMBA_PL011_H 4 - 5 - enum { 6 - REG_DR, 7 - REG_ST_DMAWM, 8 - REG_ST_TIMEOUT, 9 - REG_FR, 10 - REG_LCRH_RX, 11 - REG_LCRH_TX, 12 - REG_IBRD, 13 - REG_FBRD, 14 - REG_CR, 15 - REG_IFLS, 16 - REG_IMSC, 17 - REG_RIS, 18 - REG_MIS, 19 - REG_ICR, 20 - REG_DMACR, 21 - REG_ST_XFCR, 22 - REG_ST_XON1, 23 - REG_ST_XON2, 24 - REG_ST_XOFF1, 25 - REG_ST_XOFF2, 26 - REG_ST_ITCR, 27 - REG_ST_ITIP, 28 - REG_ST_ABCR, 29 - REG_ST_ABIMSC, 30 - 31 - /* The size of the array - must be last */ 32 - REG_ARRAY_SIZE, 33 - }; 34 - 35 - #endif
+1 -3
drivers/tty/serial/atmel_serial.c
··· 299 299 /* Resetting serial mode to RS232 (0x0) */ 300 300 mode &= ~ATMEL_US_USMODE; 301 301 302 - port->rs485 = *rs485conf; 303 - 304 302 if (rs485conf->flags & SER_RS485_ENABLED) { 305 303 dev_dbg(port->dev, "Setting UART to RS485\n"); 306 - if (port->rs485.flags & SER_RS485_RX_DURING_TX) 304 + if (rs485conf->flags & SER_RS485_RX_DURING_TX) 307 305 atmel_port->tx_done_mask = ATMEL_US_TXRDY; 308 306 else 309 307 atmel_port->tx_done_mask = ATMEL_US_TXEMPTY;
+2
drivers/tty/serial/cpm_uart/cpm_uart.h
··· 19 19 #include "cpm_uart_cpm2.h" 20 20 #elif defined(CONFIG_CPM1) 21 21 #include "cpm_uart_cpm1.h" 22 + #elif defined(CONFIG_COMPILE_TEST) 23 + #include "cpm_uart_cpm2.h" 22 24 #endif 23 25 24 26 #define SERIAL_CPM_MAJOR 204
+1 -1
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 1247 1247 } 1248 1248 1249 1249 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM 1250 - #ifdef CONFIG_CONSOLE_POLL 1250 + #if defined(CONFIG_CONSOLE_POLL) && defined(CONFIG_SERIAL_CPM_CONSOLE) 1251 1251 if (!udbg_port) 1252 1252 #endif 1253 1253 udbg_putc = NULL;
-1
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
··· 25 25 #include <asm/io.h> 26 26 #include <asm/irq.h> 27 27 #include <asm/fs_pd.h> 28 - #include <asm/prom.h> 29 28 30 29 #include <linux/serial_core.h> 31 30 #include <linux/kernel.h>
+2
drivers/tty/serial/digicolor-usart.c
··· 309 309 case CS8: 310 310 default: 311 311 config |= UA_CONFIG_CHAR_LEN; 312 + termios->c_cflag &= ~CSIZE; 313 + termios->c_cflag |= CS8; 312 314 break; 313 315 } 314 316
+8 -58
drivers/tty/serial/fsl_lpuart.c
··· 239 239 /* IMX lpuart has four extra unused regs located at the beginning */ 240 240 #define IMX_REG_OFF 0x10 241 241 242 - static DEFINE_IDA(fsl_lpuart_ida); 243 - 244 242 enum lpuart_type { 245 243 VF610_LPUART, 246 244 LS1021A_LPUART, ··· 274 276 int rx_dma_rng_buf_len; 275 277 unsigned int dma_tx_nents; 276 278 wait_queue_head_t dma_wait; 277 - bool id_allocated; 278 279 }; 279 280 280 281 struct lpuart_soc_data { ··· 1115 1118 struct dma_chan *chan = sport->dma_rx_chan; 1116 1119 struct circ_buf *ring = &sport->rx_ring; 1117 1120 unsigned long flags; 1118 - int count = 0, copied; 1121 + int count, copied; 1119 1122 1120 1123 if (lpuart_is_32(sport)) { 1121 1124 unsigned long sr = lpuart32_read(&sport->port, UARTSTAT); ··· 1375 1378 modem |= UARTMODEM_TXRTSE; 1376 1379 1377 1380 /* 1378 - * RTS needs to be logic HIGH either during transfer _or_ after 1379 - * transfer, other variants are not supported by the hardware. 1380 - */ 1381 - 1382 - if (!(rs485->flags & (SER_RS485_RTS_ON_SEND | 1383 - SER_RS485_RTS_AFTER_SEND))) 1384 - rs485->flags |= SER_RS485_RTS_ON_SEND; 1385 - 1386 - if (rs485->flags & SER_RS485_RTS_ON_SEND && 1387 - rs485->flags & SER_RS485_RTS_AFTER_SEND) 1388 - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; 1389 - 1390 - /* 1391 1381 * The hardware defaults to RTS logic HIGH while transfer. 1392 1382 * Switch polarity in case RTS shall be logic HIGH 1393 1383 * after transfer. ··· 1385 1401 else if (rs485->flags & SER_RS485_RTS_AFTER_SEND) 1386 1402 modem |= UARTMODEM_TXRTSPOL; 1387 1403 } 1388 - 1389 - /* Store the new configuration */ 1390 - sport->port.rs485 = *rs485; 1391 1404 1392 1405 writeb(modem, sport->port.membase + UARTMODEM); 1393 1406 return 0; ··· 1410 1429 modem |= UARTMODEM_TXRTSE; 1411 1430 1412 1431 /* 1413 - * RTS needs to be logic HIGH either during transfer _or_ after 1414 - * transfer, other variants are not supported by the hardware. 1415 - */ 1416 - 1417 - if (!(rs485->flags & (SER_RS485_RTS_ON_SEND | 1418 - SER_RS485_RTS_AFTER_SEND))) 1419 - rs485->flags |= SER_RS485_RTS_ON_SEND; 1420 - 1421 - if (rs485->flags & SER_RS485_RTS_ON_SEND && 1422 - rs485->flags & SER_RS485_RTS_AFTER_SEND) 1423 - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; 1424 - 1425 - /* 1426 1432 * The hardware defaults to RTS logic HIGH while transfer. 1427 1433 * Switch polarity in case RTS shall be logic HIGH 1428 1434 * after transfer. ··· 1420 1452 else if (rs485->flags & SER_RS485_RTS_AFTER_SEND) 1421 1453 modem |= UARTMODEM_TXRTSPOL; 1422 1454 } 1423 - 1424 - /* Store the new configuration */ 1425 - sport->port.rs485 = *rs485; 1426 1455 1427 1456 lpuart32_write(&sport->port, modem, UARTMODIR); 1428 1457 return 0; ··· 2110 2145 if (sport->port.rs485.flags & SER_RS485_ENABLED) 2111 2146 termios->c_cflag &= ~CRTSCTS; 2112 2147 2113 - if (termios->c_cflag & CRTSCTS) { 2114 - modem |= (UARTMODIR_RXRTSE | UARTMODIR_TXCTSE); 2115 - } else { 2116 - termios->c_cflag &= ~CRTSCTS; 2148 + if (termios->c_cflag & CRTSCTS) 2149 + modem |= UARTMODIR_RXRTSE | UARTMODIR_TXCTSE; 2150 + else 2117 2151 modem &= ~(UARTMODIR_RXRTSE | UARTMODIR_TXCTSE); 2118 - } 2119 2152 2120 2153 if (termios->c_cflag & CSTOPB) 2121 2154 bd |= UARTBAUD_SBNS; ··· 2680 2717 2681 2718 ret = of_alias_get_id(np, "serial"); 2682 2719 if (ret < 0) { 2683 - ret = ida_simple_get(&fsl_lpuart_ida, 0, UART_NR, GFP_KERNEL); 2684 - if (ret < 0) { 2685 - dev_err(&pdev->dev, "port line is full, add device failed\n"); 2686 - return ret; 2687 - } 2688 - sport->id_allocated = true; 2720 + dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret); 2721 + return ret; 2689 2722 } 2690 2723 if (ret >= ARRAY_SIZE(lpuart_ports)) { 2691 2724 dev_err(&pdev->dev, "serial%d out of range\n", ret); 2692 - ret = -EINVAL; 2693 - goto failed_out_of_range; 2725 + return -EINVAL; 2694 2726 } 2695 2727 sport->port.line = ret; 2696 2728 2697 2729 ret = lpuart_enable_clks(sport); 2698 2730 if (ret) 2699 - goto failed_clock_enable; 2731 + return ret; 2700 2732 sport->port.uartclk = lpuart_get_baud_clk_rate(sport); 2701 2733 2702 2734 lpuart_ports[sport->port.line] = sport; ··· 2739 2781 uart_remove_one_port(&lpuart_reg, &sport->port); 2740 2782 failed_attach_port: 2741 2783 lpuart_disable_clks(sport); 2742 - failed_clock_enable: 2743 - failed_out_of_range: 2744 - if (sport->id_allocated) 2745 - ida_simple_remove(&fsl_lpuart_ida, sport->port.line); 2746 2784 return ret; 2747 2785 } 2748 2786 ··· 2747 2793 struct lpuart_port *sport = platform_get_drvdata(pdev); 2748 2794 2749 2795 uart_remove_one_port(&lpuart_reg, &sport->port); 2750 - 2751 - if (sport->id_allocated) 2752 - ida_simple_remove(&fsl_lpuart_ida, sport->port.line); 2753 2796 2754 2797 lpuart_disable_clks(sport); 2755 2798 ··· 2877 2926 2878 2927 static void __exit lpuart_serial_exit(void) 2879 2928 { 2880 - ida_destroy(&fsl_lpuart_ida); 2881 2929 platform_driver_unregister(&lpuart_driver); 2882 2930 uart_unregister_driver(&lpuart_reg); 2883 2931 }
+386 -152
drivers/tty/serial/icom.c
··· 19 19 #include <linux/fs.h> 20 20 #include <linux/tty_flip.h> 21 21 #include <linux/serial.h> 22 + #include <linux/serial_core.h> 22 23 #include <linux/serial_reg.h> 23 24 #include <linux/major.h> 24 25 #include <linux/string.h> ··· 42 41 #include <asm/irq.h> 43 42 #include <linux/uaccess.h> 44 43 45 - #include "icom.h" 46 - 47 44 /*#define ICOM_TRACE enable port trace capabilities */ 48 45 49 46 #define ICOM_DRIVER_NAME "icom" 50 - #define ICOM_VERSION_STR "1.3.1" 51 47 #define NR_PORTS 128 52 - #define ICOM_PORT ((struct icom_port *)port) 53 - #define to_icom_adapter(d) container_of(d, struct icom_adapter, kref) 48 + 49 + static const unsigned int icom_acfg_baud[] = { 50 + 300, 51 + 600, 52 + 900, 53 + 1200, 54 + 1800, 55 + 2400, 56 + 3600, 57 + 4800, 58 + 7200, 59 + 9600, 60 + 14400, 61 + 19200, 62 + 28800, 63 + 38400, 64 + 57600, 65 + 76800, 66 + 115200, 67 + 153600, 68 + 230400, 69 + 307200, 70 + 460800, 71 + }; 72 + #define BAUD_TABLE_LIMIT (ARRAY_SIZE(icom_acfg_baud) - 1) 73 + 74 + struct icom_regs { 75 + u32 control; /* Adapter Control Register */ 76 + u32 interrupt; /* Adapter Interrupt Register */ 77 + u32 int_mask; /* Adapter Interrupt Mask Reg */ 78 + u32 int_pri; /* Adapter Interrupt Priority r */ 79 + u32 int_reg_b; /* Adapter non-masked Interrupt */ 80 + u32 resvd01; 81 + u32 resvd02; 82 + u32 resvd03; 83 + u32 control_2; /* Adapter Control Register 2 */ 84 + u32 interrupt_2; /* Adapter Interrupt Register 2 */ 85 + u32 int_mask_2; /* Adapter Interrupt Mask 2 */ 86 + u32 int_pri_2; /* Adapter Interrupt Prior 2 */ 87 + u32 int_reg_2b; /* Adapter non-masked 2 */ 88 + }; 89 + 90 + struct func_dram { 91 + u32 reserved[108]; /* 0-1B0 reserved by personality code */ 92 + u32 RcvStatusAddr; /* 1B0-1B3 Status Address for Next rcv */ 93 + u8 RcvStnAddr; /* 1B4 Receive Station Addr */ 94 + u8 IdleState; /* 1B5 Idle State */ 95 + u8 IdleMonitor; /* 1B6 Idle Monitor */ 96 + u8 FlagFillIdleTimer; /* 1B7 Flag Fill Idle Timer */ 97 + u32 XmitStatusAddr; /* 1B8-1BB Transmit Status Address */ 98 + u8 StartXmitCmd; /* 1BC Start Xmit Command */ 99 + u8 HDLCConfigReg; /* 1BD Reserved */ 100 + u8 CauseCode; /* 1BE Cause code for fatal error */ 101 + u8 xchar; /* 1BF High priority send */ 102 + u32 reserved3; /* 1C0-1C3 Reserved */ 103 + u8 PrevCmdReg; /* 1C4 Reserved */ 104 + u8 CmdReg; /* 1C5 Command Register */ 105 + u8 async_config2; /* 1C6 Async Config Byte 2 */ 106 + u8 async_config3; /* 1C7 Async Config Byte 3 */ 107 + u8 dce_resvd[20]; /* 1C8-1DB DCE Rsvd */ 108 + u8 dce_resvd21; /* 1DC DCE Rsvd (21st byte */ 109 + u8 misc_flags; /* 1DD misc flags */ 110 + #define V2_HARDWARE 0x40 111 + #define ICOM_HDW_ACTIVE 0x01 112 + u8 call_length; /* 1DE Phone #/CFI buff ln */ 113 + u8 call_length2; /* 1DF Upper byte (unused) */ 114 + u32 call_addr; /* 1E0-1E3 Phn #/CFI buff addr */ 115 + u16 timer_value; /* 1E4-1E5 general timer value */ 116 + u8 timer_command; /* 1E6 general timer cmd */ 117 + u8 dce_command; /* 1E7 dce command reg */ 118 + u8 dce_cmd_status; /* 1E8 dce command stat */ 119 + u8 x21_r1_ioff; /* 1E9 dce ready counter */ 120 + u8 x21_r0_ioff; /* 1EA dce not ready ctr */ 121 + u8 x21_ralt_ioff; /* 1EB dce CNR counter */ 122 + u8 x21_r1_ion; /* 1EC dce ready I on ctr */ 123 + u8 rsvd_ier; /* 1ED Rsvd for IER (if ne */ 124 + u8 ier; /* 1EE Interrupt Enable */ 125 + u8 isr; /* 1EF Input Signal Reg */ 126 + u8 osr; /* 1F0 Output Signal Reg */ 127 + u8 reset; /* 1F1 Reset/Reload Reg */ 128 + u8 disable; /* 1F2 Disable Reg */ 129 + u8 sync; /* 1F3 Sync Reg */ 130 + u8 error_stat; /* 1F4 Error Status */ 131 + u8 cable_id; /* 1F5 Cable ID */ 132 + u8 cs_length; /* 1F6 CS Load Length */ 133 + u8 mac_length; /* 1F7 Mac Load Length */ 134 + u32 cs_load_addr; /* 1F8-1FB Call Load PCI Addr */ 135 + u32 mac_load_addr; /* 1FC-1FF Mac Load PCI Addr */ 136 + }; 137 + 138 + /* 139 + * adapter defines and structures 140 + */ 141 + #define ICOM_CONTROL_START_A 0x00000008 142 + #define ICOM_CONTROL_STOP_A 0x00000004 143 + #define ICOM_CONTROL_START_B 0x00000002 144 + #define ICOM_CONTROL_STOP_B 0x00000001 145 + #define ICOM_CONTROL_START_C 0x00000008 146 + #define ICOM_CONTROL_STOP_C 0x00000004 147 + #define ICOM_CONTROL_START_D 0x00000002 148 + #define ICOM_CONTROL_STOP_D 0x00000001 149 + #define ICOM_IRAM_OFFSET 0x1000 150 + #define ICOM_IRAM_SIZE 0x0C00 151 + #define ICOM_DCE_IRAM_OFFSET 0x0A00 152 + #define ICOM_CABLE_ID_VALID 0x01 153 + #define ICOM_CABLE_ID_MASK 0xF0 154 + #define ICOM_DISABLE 0x80 155 + #define CMD_XMIT_RCV_ENABLE 0xC0 156 + #define CMD_XMIT_ENABLE 0x40 157 + #define CMD_RCV_DISABLE 0x00 158 + #define CMD_RCV_ENABLE 0x80 159 + #define CMD_RESTART 0x01 160 + #define CMD_HOLD_XMIT 0x02 161 + #define CMD_SND_BREAK 0x04 162 + #define RS232_CABLE 0x06 163 + #define V24_CABLE 0x0E 164 + #define V35_CABLE 0x0C 165 + #define V36_CABLE 0x02 166 + #define NO_CABLE 0x00 167 + #define START_DOWNLOAD 0x80 168 + #define ICOM_INT_MASK_PRC_A 0x00003FFF 169 + #define ICOM_INT_MASK_PRC_B 0x3FFF0000 170 + #define ICOM_INT_MASK_PRC_C 0x00003FFF 171 + #define ICOM_INT_MASK_PRC_D 0x3FFF0000 172 + #define INT_RCV_COMPLETED 0x1000 173 + #define INT_XMIT_COMPLETED 0x2000 174 + #define INT_IDLE_DETECT 0x0800 175 + #define INT_RCV_DISABLED 0x0400 176 + #define INT_XMIT_DISABLED 0x0200 177 + #define INT_RCV_XMIT_SHUTDOWN 0x0100 178 + #define INT_FATAL_ERROR 0x0080 179 + #define INT_CABLE_PULL 0x0020 180 + #define INT_SIGNAL_CHANGE 0x0010 181 + #define HDLC_PPP_PURE_ASYNC 0x02 182 + #define HDLC_FF_FILL 0x00 183 + #define HDLC_HDW_FLOW 0x01 184 + #define START_XMIT 0x80 185 + #define ICOM_ACFG_DRIVE1 0x20 186 + #define ICOM_ACFG_NO_PARITY 0x00 187 + #define ICOM_ACFG_PARITY_ENAB 0x02 188 + #define ICOM_ACFG_PARITY_ODD 0x01 189 + #define ICOM_ACFG_8BPC 0x00 190 + #define ICOM_ACFG_7BPC 0x04 191 + #define ICOM_ACFG_6BPC 0x08 192 + #define ICOM_ACFG_5BPC 0x0C 193 + #define ICOM_ACFG_1STOP_BIT 0x00 194 + #define ICOM_ACFG_2STOP_BIT 0x10 195 + #define ICOM_DTR 0x80 196 + #define ICOM_RTS 0x40 197 + #define ICOM_RI 0x08 198 + #define ICOM_DSR 0x80 199 + #define ICOM_DCD 0x20 200 + #define ICOM_CTS 0x40 201 + 202 + #define NUM_XBUFFS 1 203 + #define NUM_RBUFFS 2 204 + #define RCV_BUFF_SZ 0x0200 205 + #define XMIT_BUFF_SZ 0x1000 206 + struct statusArea { 207 + /**********************************************/ 208 + /* Transmit Status Area */ 209 + /**********************************************/ 210 + struct xmit_status_area{ 211 + __le32 leNext; /* Next entry in Little Endian on Adapter */ 212 + __le32 leNextASD; 213 + __le32 leBuffer; /* Buffer for entry in LE for Adapter */ 214 + __le16 leLengthASD; 215 + __le16 leOffsetASD; 216 + __le16 leLength; /* Length of data in segment */ 217 + __le16 flags; 218 + #define SA_FLAGS_DONE 0x0080 /* Done with Segment */ 219 + #define SA_FLAGS_CONTINUED 0x8000 /* More Segments */ 220 + #define SA_FLAGS_IDLE 0x4000 /* Mark IDLE after frm */ 221 + #define SA_FLAGS_READY_TO_XMIT 0x0800 222 + #define SA_FLAGS_STAT_MASK 0x007F 223 + } xmit[NUM_XBUFFS]; 224 + 225 + /**********************************************/ 226 + /* Receive Status Area */ 227 + /**********************************************/ 228 + struct { 229 + __le32 leNext; /* Next entry in Little Endian on Adapter */ 230 + __le32 leNextASD; 231 + __le32 leBuffer; /* Buffer for entry in LE for Adapter */ 232 + __le16 WorkingLength; /* size of segment */ 233 + __le16 reserv01; 234 + __le16 leLength; /* Length of data in segment */ 235 + __le16 flags; 236 + #define SA_FL_RCV_DONE 0x0010 /* Data ready */ 237 + #define SA_FLAGS_OVERRUN 0x0040 238 + #define SA_FLAGS_PARITY_ERROR 0x0080 239 + #define SA_FLAGS_FRAME_ERROR 0x0001 240 + #define SA_FLAGS_FRAME_TRUNC 0x0002 241 + #define SA_FLAGS_BREAK_DET 0x0004 /* set conditionally by device driver, not hardware */ 242 + #define SA_FLAGS_RCV_MASK 0xFFE6 243 + } rcv[NUM_RBUFFS]; 244 + }; 245 + 246 + struct icom_adapter; 247 + 248 + 249 + #define ICOM_MAJOR 243 250 + #define ICOM_MINOR_START 0 251 + 252 + struct icom_port { 253 + struct uart_port uart_port; 254 + unsigned char cable_id; 255 + unsigned char read_status_mask; 256 + unsigned char ignore_status_mask; 257 + void __iomem * int_reg; 258 + struct icom_regs __iomem *global_reg; 259 + struct func_dram __iomem *dram; 260 + int port; 261 + struct statusArea *statStg; 262 + dma_addr_t statStg_pci; 263 + __le32 *xmitRestart; 264 + dma_addr_t xmitRestart_pci; 265 + unsigned char *xmit_buf; 266 + dma_addr_t xmit_buf_pci; 267 + unsigned char *recv_buf; 268 + dma_addr_t recv_buf_pci; 269 + int next_rcv; 270 + int status; 271 + #define ICOM_PORT_ACTIVE 1 /* Port exists. */ 272 + #define ICOM_PORT_OFF 0 /* Port does not exist. */ 273 + struct icom_adapter *adapter; 274 + }; 275 + 276 + struct icom_adapter { 277 + void __iomem * base_addr; 278 + unsigned long base_addr_pci; 279 + struct pci_dev *pci_dev; 280 + struct icom_port port_info[4]; 281 + int index; 282 + int version; 283 + #define ADAPTER_V1 0x0001 284 + #define ADAPTER_V2 0x0002 285 + u32 subsystem_id; 286 + #define FOUR_PORT_MODEL 0x0252 287 + #define V2_TWO_PORTS_RVX 0x021A 288 + #define V2_ONE_PORT_RVX_ONE_PORT_IMBED_MDM 0x0251 289 + int numb_ports; 290 + struct list_head icom_adapter_entry; 291 + struct kref kref; 292 + }; 293 + 294 + /* prototype */ 295 + extern void iCom_sercons_init(void); 296 + 297 + struct lookup_proc_table { 298 + u32 __iomem *global_control_reg; 299 + unsigned long processor_id; 300 + }; 301 + 302 + struct lookup_int_table { 303 + u32 __iomem *global_int_mask; 304 + unsigned long processor_id; 305 + }; 306 + 307 + static inline struct icom_port *to_icom_port(struct uart_port *port) 308 + { 309 + return container_of(port, struct icom_port, uart_port); 310 + } 54 311 55 312 static const struct pci_device_id icom_pci_table[] = { 56 313 { ··· 481 222 if (index < (NUM_XBUFFS - 1)) { 482 223 memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area)); 483 224 icom_port->statStg->xmit[index].leLengthASD = 484 - (unsigned short int) cpu_to_le16(XMIT_BUFF_SZ); 225 + cpu_to_le16(XMIT_BUFF_SZ); 485 226 trace(icom_port, "FOD_ADDR", stgAddr); 486 227 trace(icom_port, "FOD_XBUFF", 487 228 (unsigned long) icom_port->xmit_buf); ··· 490 231 } else if (index == (NUM_XBUFFS - 1)) { 491 232 memset(&icom_port->statStg->xmit[index], 0, sizeof(struct xmit_status_area)); 492 233 icom_port->statStg->xmit[index].leLengthASD = 493 - (unsigned short int) cpu_to_le16(XMIT_BUFF_SZ); 234 + cpu_to_le16(XMIT_BUFF_SZ); 494 235 trace(icom_port, "FOD_XBUFF", 495 236 (unsigned long) icom_port->xmit_buf); 496 237 icom_port->statStg->xmit[index].leBuffer = ··· 508 249 stgAddr = stgAddr + sizeof(icom_port->statStg->rcv[0]); 509 250 icom_port->statStg->rcv[index].leLength = 0; 510 251 icom_port->statStg->rcv[index].WorkingLength = 511 - (unsigned short int) cpu_to_le16(RCV_BUFF_SZ); 252 + cpu_to_le16(RCV_BUFF_SZ); 512 253 if (index < (NUM_RBUFFS - 1) ) { 513 254 offset = stgAddr - (unsigned long) icom_port->statStg; 514 255 icom_port->statStg->rcv[index].leNext = ··· 876 617 877 618 static int icom_write(struct uart_port *port) 878 619 { 620 + struct icom_port *icom_port = to_icom_port(port); 879 621 unsigned long data_count; 880 622 unsigned char cmdReg; 881 623 unsigned long offset; 882 624 int temp_tail = port->state->xmit.tail; 883 625 884 - trace(ICOM_PORT, "WRITE", 0); 626 + trace(icom_port, "WRITE", 0); 885 627 886 - if (cpu_to_le16(ICOM_PORT->statStg->xmit[0].flags) & 628 + if (le16_to_cpu(icom_port->statStg->xmit[0].flags) & 887 629 SA_FLAGS_READY_TO_XMIT) { 888 - trace(ICOM_PORT, "WRITE_FULL", 0); 630 + trace(icom_port, "WRITE_FULL", 0); 889 631 return 0; 890 632 } 891 633 ··· 894 634 while ((port->state->xmit.head != temp_tail) && 895 635 (data_count <= XMIT_BUFF_SZ)) { 896 636 897 - ICOM_PORT->xmit_buf[data_count++] = 637 + icom_port->xmit_buf[data_count++] = 898 638 port->state->xmit.buf[temp_tail]; 899 639 900 640 temp_tail++; ··· 902 642 } 903 643 904 644 if (data_count) { 905 - ICOM_PORT->statStg->xmit[0].flags = 645 + icom_port->statStg->xmit[0].flags = 906 646 cpu_to_le16(SA_FLAGS_READY_TO_XMIT); 907 - ICOM_PORT->statStg->xmit[0].leLength = 647 + icom_port->statStg->xmit[0].leLength = 908 648 cpu_to_le16(data_count); 909 649 offset = 910 - (unsigned long) &ICOM_PORT->statStg->xmit[0] - 911 - (unsigned long) ICOM_PORT->statStg; 912 - *ICOM_PORT->xmitRestart = 913 - cpu_to_le32(ICOM_PORT->statStg_pci + offset); 914 - cmdReg = readb(&ICOM_PORT->dram->CmdReg); 650 + (unsigned long) &icom_port->statStg->xmit[0] - 651 + (unsigned long) icom_port->statStg; 652 + *icom_port->xmitRestart = 653 + cpu_to_le32(icom_port->statStg_pci + offset); 654 + cmdReg = readb(&icom_port->dram->CmdReg); 915 655 writeb(cmdReg | CMD_XMIT_RCV_ENABLE, 916 - &ICOM_PORT->dram->CmdReg); 917 - writeb(START_XMIT, &ICOM_PORT->dram->StartXmitCmd); 918 - trace(ICOM_PORT, "WRITE_START", data_count); 656 + &icom_port->dram->CmdReg); 657 + writeb(START_XMIT, &icom_port->dram->StartXmitCmd); 658 + trace(icom_port, "WRITE_START", data_count); 919 659 /* write flush */ 920 - readb(&ICOM_PORT->dram->StartXmitCmd); 660 + readb(&icom_port->dram->StartXmitCmd); 921 661 } 922 662 923 663 return data_count; ··· 956 696 957 697 static void xmit_interrupt(u16 port_int_reg, struct icom_port *icom_port) 958 698 { 959 - unsigned short int count; 960 - int i; 699 + u16 count, i; 961 700 962 701 if (port_int_reg & (INT_XMIT_COMPLETED)) { 963 702 trace(icom_port, "XMIT_COMPLETE", 0); ··· 965 706 icom_port->statStg->xmit[0].flags &= 966 707 cpu_to_le16(~SA_FLAGS_READY_TO_XMIT); 967 708 968 - count = (unsigned short int) 969 - cpu_to_le16(icom_port->statStg->xmit[0].leLength); 709 + count = le16_to_cpu(icom_port->statStg->xmit[0].leLength); 970 710 icom_port->uart_port.icount.tx += count; 971 711 972 712 for (i=0; i<count && ··· 987 729 { 988 730 short int count, rcv_buff; 989 731 struct tty_port *port = &icom_port->uart_port.state->port; 990 - unsigned short int status; 732 + u16 status; 991 733 struct uart_icount *icount; 992 734 unsigned long offset; 993 735 unsigned char flag; ··· 995 737 trace(icom_port, "RCV_COMPLETE", 0); 996 738 rcv_buff = icom_port->next_rcv; 997 739 998 - status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); 740 + status = le16_to_cpu(icom_port->statStg->rcv[rcv_buff].flags); 999 741 while (status & SA_FL_RCV_DONE) { 1000 742 int first = -1; 1001 743 1002 744 trace(icom_port, "FID_STATUS", status); 1003 - count = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].leLength); 745 + count = le16_to_cpu(icom_port->statStg->rcv[rcv_buff].leLength); 1004 746 1005 747 trace(icom_port, "RCV_COUNT", count); 1006 748 1007 749 trace(icom_port, "REAL_COUNT", count); 1008 750 1009 - offset = 1010 - cpu_to_le32(icom_port->statStg->rcv[rcv_buff].leBuffer) - 751 + offset = le32_to_cpu(icom_port->statStg->rcv[rcv_buff].leBuffer) - 1011 752 icom_port->recv_buf_pci; 1012 753 1013 754 /* Block copy all but the last byte as this may have status */ ··· 1076 819 icom_port->statStg->rcv[rcv_buff].flags = 0; 1077 820 icom_port->statStg->rcv[rcv_buff].leLength = 0; 1078 821 icom_port->statStg->rcv[rcv_buff].WorkingLength = 1079 - (unsigned short int) cpu_to_le16(RCV_BUFF_SZ); 822 + cpu_to_le16(RCV_BUFF_SZ); 1080 823 1081 824 rcv_buff++; 1082 825 if (rcv_buff == NUM_RBUFFS) 1083 826 rcv_buff = 0; 1084 827 1085 - status = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].flags); 828 + status = le16_to_cpu(icom_port->statStg->rcv[rcv_buff].flags); 1086 829 } 1087 830 icom_port->next_rcv = rcv_buff; 1088 831 ··· 1182 925 */ 1183 926 static unsigned int icom_tx_empty(struct uart_port *port) 1184 927 { 928 + struct icom_port *icom_port = to_icom_port(port); 1185 929 int ret; 1186 930 unsigned long flags; 1187 931 1188 932 spin_lock_irqsave(&port->lock, flags); 1189 - if (cpu_to_le16(ICOM_PORT->statStg->xmit[0].flags) & 933 + if (le16_to_cpu(icom_port->statStg->xmit[0].flags) & 1190 934 SA_FLAGS_READY_TO_XMIT) 1191 935 ret = TIOCSER_TEMT; 1192 936 else ··· 1199 941 1200 942 static void icom_set_mctrl(struct uart_port *port, unsigned int mctrl) 1201 943 { 944 + struct icom_port *icom_port = to_icom_port(port); 1202 945 unsigned char local_osr; 1203 946 1204 - trace(ICOM_PORT, "SET_MODEM", 0); 1205 - local_osr = readb(&ICOM_PORT->dram->osr); 947 + trace(icom_port, "SET_MODEM", 0); 948 + local_osr = readb(&icom_port->dram->osr); 1206 949 1207 950 if (mctrl & TIOCM_RTS) { 1208 - trace(ICOM_PORT, "RAISE_RTS", 0); 951 + trace(icom_port, "RAISE_RTS", 0); 1209 952 local_osr |= ICOM_RTS; 1210 953 } else { 1211 - trace(ICOM_PORT, "LOWER_RTS", 0); 954 + trace(icom_port, "LOWER_RTS", 0); 1212 955 local_osr &= ~ICOM_RTS; 1213 956 } 1214 957 1215 958 if (mctrl & TIOCM_DTR) { 1216 - trace(ICOM_PORT, "RAISE_DTR", 0); 959 + trace(icom_port, "RAISE_DTR", 0); 1217 960 local_osr |= ICOM_DTR; 1218 961 } else { 1219 - trace(ICOM_PORT, "LOWER_DTR", 0); 962 + trace(icom_port, "LOWER_DTR", 0); 1220 963 local_osr &= ~ICOM_DTR; 1221 964 } 1222 965 1223 - writeb(local_osr, &ICOM_PORT->dram->osr); 966 + writeb(local_osr, &icom_port->dram->osr); 1224 967 } 1225 968 1226 969 static unsigned int icom_get_mctrl(struct uart_port *port) 1227 970 { 971 + struct icom_port *icom_port = to_icom_port(port); 1228 972 unsigned char status; 1229 973 unsigned int result; 1230 974 1231 - trace(ICOM_PORT, "GET_MODEM", 0); 975 + trace(icom_port, "GET_MODEM", 0); 1232 976 1233 - status = readb(&ICOM_PORT->dram->isr); 977 + status = readb(&icom_port->dram->isr); 1234 978 1235 979 result = ((status & ICOM_DCD) ? TIOCM_CAR : 0) 1236 980 | ((status & ICOM_RI) ? TIOCM_RNG : 0) ··· 1243 983 1244 984 static void icom_stop_tx(struct uart_port *port) 1245 985 { 986 + struct icom_port *icom_port = to_icom_port(port); 1246 987 unsigned char cmdReg; 1247 988 1248 - trace(ICOM_PORT, "STOP", 0); 1249 - cmdReg = readb(&ICOM_PORT->dram->CmdReg); 1250 - writeb(cmdReg | CMD_HOLD_XMIT, &ICOM_PORT->dram->CmdReg); 989 + trace(icom_port, "STOP", 0); 990 + cmdReg = readb(&icom_port->dram->CmdReg); 991 + writeb(cmdReg | CMD_HOLD_XMIT, &icom_port->dram->CmdReg); 1251 992 } 1252 993 1253 994 static void icom_start_tx(struct uart_port *port) 1254 995 { 996 + struct icom_port *icom_port = to_icom_port(port); 1255 997 unsigned char cmdReg; 1256 998 1257 - trace(ICOM_PORT, "START", 0); 1258 - cmdReg = readb(&ICOM_PORT->dram->CmdReg); 999 + trace(icom_port, "START", 0); 1000 + cmdReg = readb(&icom_port->dram->CmdReg); 1259 1001 if ((cmdReg & CMD_HOLD_XMIT) == CMD_HOLD_XMIT) 1260 1002 writeb(cmdReg & ~CMD_HOLD_XMIT, 1261 - &ICOM_PORT->dram->CmdReg); 1003 + &icom_port->dram->CmdReg); 1262 1004 1263 1005 icom_write(port); 1264 1006 } 1265 1007 1266 1008 static void icom_send_xchar(struct uart_port *port, char ch) 1267 1009 { 1010 + struct icom_port *icom_port = to_icom_port(port); 1268 1011 unsigned char xdata; 1269 1012 int index; 1270 1013 unsigned long flags; 1271 1014 1272 - trace(ICOM_PORT, "SEND_XCHAR", ch); 1015 + trace(icom_port, "SEND_XCHAR", ch); 1273 1016 1274 1017 /* wait .1 sec to send char */ 1275 1018 for (index = 0; index < 10; index++) { 1276 1019 spin_lock_irqsave(&port->lock, flags); 1277 - xdata = readb(&ICOM_PORT->dram->xchar); 1020 + xdata = readb(&icom_port->dram->xchar); 1278 1021 if (xdata == 0x00) { 1279 - trace(ICOM_PORT, "QUICK_WRITE", 0); 1280 - writeb(ch, &ICOM_PORT->dram->xchar); 1022 + trace(icom_port, "QUICK_WRITE", 0); 1023 + writeb(ch, &icom_port->dram->xchar); 1281 1024 1282 1025 /* flush write operation */ 1283 - xdata = readb(&ICOM_PORT->dram->xchar); 1026 + xdata = readb(&icom_port->dram->xchar); 1284 1027 spin_unlock_irqrestore(&port->lock, flags); 1285 1028 break; 1286 1029 } ··· 1294 1031 1295 1032 static void icom_stop_rx(struct uart_port *port) 1296 1033 { 1034 + struct icom_port *icom_port = to_icom_port(port); 1297 1035 unsigned char cmdReg; 1298 1036 1299 - cmdReg = readb(&ICOM_PORT->dram->CmdReg); 1300 - writeb(cmdReg & ~CMD_RCV_ENABLE, &ICOM_PORT->dram->CmdReg); 1037 + cmdReg = readb(&icom_port->dram->CmdReg); 1038 + writeb(cmdReg & ~CMD_RCV_ENABLE, &icom_port->dram->CmdReg); 1301 1039 } 1302 1040 1303 1041 static void icom_break(struct uart_port *port, int break_state) 1304 1042 { 1043 + struct icom_port *icom_port = to_icom_port(port); 1305 1044 unsigned char cmdReg; 1306 1045 unsigned long flags; 1307 1046 1308 1047 spin_lock_irqsave(&port->lock, flags); 1309 - trace(ICOM_PORT, "BREAK", 0); 1310 - cmdReg = readb(&ICOM_PORT->dram->CmdReg); 1048 + trace(icom_port, "BREAK", 0); 1049 + cmdReg = readb(&icom_port->dram->CmdReg); 1311 1050 if (break_state == -1) { 1312 - writeb(cmdReg | CMD_SND_BREAK, &ICOM_PORT->dram->CmdReg); 1051 + writeb(cmdReg | CMD_SND_BREAK, &icom_port->dram->CmdReg); 1313 1052 } else { 1314 - writeb(cmdReg & ~CMD_SND_BREAK, &ICOM_PORT->dram->CmdReg); 1053 + writeb(cmdReg & ~CMD_SND_BREAK, &icom_port->dram->CmdReg); 1315 1054 } 1316 1055 spin_unlock_irqrestore(&port->lock, flags); 1317 1056 } 1318 1057 1319 1058 static int icom_open(struct uart_port *port) 1320 1059 { 1060 + struct icom_port *icom_port = to_icom_port(port); 1321 1061 int retval; 1322 1062 1323 - kref_get(&ICOM_PORT->adapter->kref); 1324 - retval = startup(ICOM_PORT); 1063 + kref_get(&icom_port->adapter->kref); 1064 + retval = startup(icom_port); 1325 1065 1326 1066 if (retval) { 1327 - kref_put(&ICOM_PORT->adapter->kref, icom_kref_release); 1328 - trace(ICOM_PORT, "STARTUP_ERROR", 0); 1067 + kref_put(&icom_port->adapter->kref, icom_kref_release); 1068 + trace(icom_port, "STARTUP_ERROR", 0); 1329 1069 return retval; 1330 1070 } 1331 1071 ··· 1337 1071 1338 1072 static void icom_close(struct uart_port *port) 1339 1073 { 1074 + struct icom_port *icom_port = to_icom_port(port); 1340 1075 unsigned char cmdReg; 1341 1076 1342 - trace(ICOM_PORT, "CLOSE", 0); 1077 + trace(icom_port, "CLOSE", 0); 1343 1078 1344 1079 /* stop receiver */ 1345 - cmdReg = readb(&ICOM_PORT->dram->CmdReg); 1346 - writeb(cmdReg & ~CMD_RCV_ENABLE, &ICOM_PORT->dram->CmdReg); 1080 + cmdReg = readb(&icom_port->dram->CmdReg); 1081 + writeb(cmdReg & ~CMD_RCV_ENABLE, &icom_port->dram->CmdReg); 1347 1082 1348 - shutdown(ICOM_PORT); 1083 + shutdown(icom_port); 1349 1084 1350 - kref_put(&ICOM_PORT->adapter->kref, icom_kref_release); 1085 + kref_put(&icom_port->adapter->kref, icom_kref_release); 1351 1086 } 1352 1087 1353 1088 static void icom_set_termios(struct uart_port *port, 1354 1089 struct ktermios *termios, 1355 1090 struct ktermios *old_termios) 1356 1091 { 1092 + struct icom_port *icom_port = to_icom_port(port); 1357 1093 int baud; 1358 1094 unsigned cflag, iflag; 1359 1095 char new_config2; ··· 1367 1099 unsigned long flags; 1368 1100 1369 1101 spin_lock_irqsave(&port->lock, flags); 1370 - trace(ICOM_PORT, "CHANGE_SPEED", 0); 1102 + trace(icom_port, "CHANGE_SPEED", 0); 1371 1103 1372 1104 cflag = termios->c_cflag; 1373 1105 iflag = termios->c_iflag; ··· 1398 1130 if (cflag & PARENB) { 1399 1131 /* parity bit enabled */ 1400 1132 new_config2 |= ICOM_ACFG_PARITY_ENAB; 1401 - trace(ICOM_PORT, "PARENB", 0); 1133 + trace(icom_port, "PARENB", 0); 1402 1134 } 1403 1135 if (cflag & PARODD) { 1404 1136 /* odd parity */ 1405 1137 new_config2 |= ICOM_ACFG_PARITY_ODD; 1406 - trace(ICOM_PORT, "PARODD", 0); 1138 + trace(icom_port, "PARODD", 0); 1407 1139 } 1408 1140 1409 1141 /* Determine divisor based on baud rate */ ··· 1423 1155 uart_update_timeout(port, cflag, baud); 1424 1156 1425 1157 /* CTS flow control flag and modem status interrupts */ 1426 - tmp_byte = readb(&(ICOM_PORT->dram->HDLCConfigReg)); 1158 + tmp_byte = readb(&(icom_port->dram->HDLCConfigReg)); 1427 1159 if (cflag & CRTSCTS) 1428 1160 tmp_byte |= HDLC_HDW_FLOW; 1429 1161 else 1430 1162 tmp_byte &= ~HDLC_HDW_FLOW; 1431 - writeb(tmp_byte, &(ICOM_PORT->dram->HDLCConfigReg)); 1163 + writeb(tmp_byte, &(icom_port->dram->HDLCConfigReg)); 1432 1164 1433 1165 /* 1434 1166 * Set up parity check flag 1435 1167 */ 1436 - ICOM_PORT->read_status_mask = SA_FLAGS_OVERRUN | SA_FL_RCV_DONE; 1168 + icom_port->read_status_mask = SA_FLAGS_OVERRUN | SA_FL_RCV_DONE; 1437 1169 if (iflag & INPCK) 1438 - ICOM_PORT->read_status_mask |= 1170 + icom_port->read_status_mask |= 1439 1171 SA_FLAGS_FRAME_ERROR | SA_FLAGS_PARITY_ERROR; 1440 1172 1441 1173 if ((iflag & BRKINT) || (iflag & PARMRK)) 1442 - ICOM_PORT->read_status_mask |= SA_FLAGS_BREAK_DET; 1174 + icom_port->read_status_mask |= SA_FLAGS_BREAK_DET; 1443 1175 1444 1176 /* 1445 1177 * Characters to ignore 1446 1178 */ 1447 - ICOM_PORT->ignore_status_mask = 0; 1179 + icom_port->ignore_status_mask = 0; 1448 1180 if (iflag & IGNPAR) 1449 - ICOM_PORT->ignore_status_mask |= 1181 + icom_port->ignore_status_mask |= 1450 1182 SA_FLAGS_PARITY_ERROR | SA_FLAGS_FRAME_ERROR; 1451 1183 if (iflag & IGNBRK) { 1452 - ICOM_PORT->ignore_status_mask |= SA_FLAGS_BREAK_DET; 1184 + icom_port->ignore_status_mask |= SA_FLAGS_BREAK_DET; 1453 1185 /* 1454 1186 * If we're ignore parity and break indicators, ignore 1455 1187 * overruns too. (For real raw support). 1456 1188 */ 1457 1189 if (iflag & IGNPAR) 1458 - ICOM_PORT->ignore_status_mask |= SA_FLAGS_OVERRUN; 1190 + icom_port->ignore_status_mask |= SA_FLAGS_OVERRUN; 1459 1191 } 1460 1192 1461 1193 /* 1462 1194 * !!! ignore all characters if CREAD is not set 1463 1195 */ 1464 1196 if ((cflag & CREAD) == 0) 1465 - ICOM_PORT->ignore_status_mask |= SA_FL_RCV_DONE; 1197 + icom_port->ignore_status_mask |= SA_FL_RCV_DONE; 1466 1198 1467 1199 /* Turn off Receiver to prepare for reset */ 1468 - writeb(CMD_RCV_DISABLE, &ICOM_PORT->dram->CmdReg); 1200 + writeb(CMD_RCV_DISABLE, &icom_port->dram->CmdReg); 1469 1201 1470 1202 for (index = 0; index < 10; index++) { 1471 - if (readb(&ICOM_PORT->dram->PrevCmdReg) == 0x00) { 1203 + if (readb(&icom_port->dram->PrevCmdReg) == 0x00) { 1472 1204 break; 1473 1205 } 1474 1206 } 1475 1207 1476 1208 /* clear all current buffers of data */ 1477 1209 for (rcv_buff = 0; rcv_buff < NUM_RBUFFS; rcv_buff++) { 1478 - ICOM_PORT->statStg->rcv[rcv_buff].flags = 0; 1479 - ICOM_PORT->statStg->rcv[rcv_buff].leLength = 0; 1480 - ICOM_PORT->statStg->rcv[rcv_buff].WorkingLength = 1481 - (unsigned short int) cpu_to_le16(RCV_BUFF_SZ); 1210 + icom_port->statStg->rcv[rcv_buff].flags = 0; 1211 + icom_port->statStg->rcv[rcv_buff].leLength = 0; 1212 + icom_port->statStg->rcv[rcv_buff].WorkingLength = 1213 + cpu_to_le16(RCV_BUFF_SZ); 1482 1214 } 1483 1215 1484 1216 for (xmit_buff = 0; xmit_buff < NUM_XBUFFS; xmit_buff++) { 1485 - ICOM_PORT->statStg->xmit[xmit_buff].flags = 0; 1217 + icom_port->statStg->xmit[xmit_buff].flags = 0; 1486 1218 } 1487 1219 1488 1220 /* activate changes and start xmit and receiver here */ 1489 1221 /* Enable the receiver */ 1490 - writeb(new_config3, &(ICOM_PORT->dram->async_config3)); 1491 - writeb(new_config2, &(ICOM_PORT->dram->async_config2)); 1492 - tmp_byte = readb(&(ICOM_PORT->dram->HDLCConfigReg)); 1222 + writeb(new_config3, &(icom_port->dram->async_config3)); 1223 + writeb(new_config2, &(icom_port->dram->async_config2)); 1224 + tmp_byte = readb(&(icom_port->dram->HDLCConfigReg)); 1493 1225 tmp_byte |= HDLC_PPP_PURE_ASYNC | HDLC_FF_FILL; 1494 - writeb(tmp_byte, &(ICOM_PORT->dram->HDLCConfigReg)); 1495 - writeb(0x04, &(ICOM_PORT->dram->FlagFillIdleTimer)); /* 0.5 seconds */ 1496 - writeb(0xFF, &(ICOM_PORT->dram->ier)); /* enable modem signal interrupts */ 1226 + writeb(tmp_byte, &(icom_port->dram->HDLCConfigReg)); 1227 + writeb(0x04, &(icom_port->dram->FlagFillIdleTimer)); /* 0.5 seconds */ 1228 + writeb(0xFF, &(icom_port->dram->ier)); /* enable modem signal interrupts */ 1497 1229 1498 1230 /* reset processor */ 1499 - writeb(CMD_RESTART, &ICOM_PORT->dram->CmdReg); 1231 + writeb(CMD_RESTART, &icom_port->dram->CmdReg); 1500 1232 1501 1233 for (index = 0; index < 10; index++) { 1502 - if (readb(&ICOM_PORT->dram->CmdReg) == 0x00) { 1234 + if (readb(&icom_port->dram->CmdReg) == 0x00) { 1503 1235 break; 1504 1236 } 1505 1237 } 1506 1238 1507 1239 /* Enable Transmitter and Receiver */ 1508 1240 offset = 1509 - (unsigned long) &ICOM_PORT->statStg->rcv[0] - 1510 - (unsigned long) ICOM_PORT->statStg; 1511 - writel(ICOM_PORT->statStg_pci + offset, 1512 - &ICOM_PORT->dram->RcvStatusAddr); 1513 - ICOM_PORT->next_rcv = 0; 1514 - ICOM_PORT->put_length = 0; 1515 - *ICOM_PORT->xmitRestart = 0; 1516 - writel(ICOM_PORT->xmitRestart_pci, 1517 - &ICOM_PORT->dram->XmitStatusAddr); 1518 - trace(ICOM_PORT, "XR_ENAB", 0); 1519 - writeb(CMD_XMIT_RCV_ENABLE, &ICOM_PORT->dram->CmdReg); 1241 + (unsigned long) &icom_port->statStg->rcv[0] - 1242 + (unsigned long) icom_port->statStg; 1243 + writel(icom_port->statStg_pci + offset, 1244 + &icom_port->dram->RcvStatusAddr); 1245 + icom_port->next_rcv = 0; 1246 + *icom_port->xmitRestart = 0; 1247 + writel(icom_port->xmitRestart_pci, 1248 + &icom_port->dram->XmitStatusAddr); 1249 + trace(icom_port, "XR_ENAB", 0); 1250 + writeb(CMD_XMIT_RCV_ENABLE, &icom_port->dram->CmdReg); 1520 1251 1521 1252 spin_unlock_irqrestore(&port->lock, flags); 1522 1253 } ··· 1523 1256 static const char *icom_type(struct uart_port *port) 1524 1257 { 1525 1258 return "icom"; 1526 - } 1527 - 1528 - static void icom_release_port(struct uart_port *port) 1529 - { 1530 - } 1531 - 1532 - static int icom_request_port(struct uart_port *port) 1533 - { 1534 - return 0; 1535 1259 } 1536 1260 1537 1261 static void icom_config_port(struct uart_port *port, int flags) ··· 1543 1285 .shutdown = icom_close, 1544 1286 .set_termios = icom_set_termios, 1545 1287 .type = icom_type, 1546 - .release_port = icom_release_port, 1547 - .request_port = icom_request_port, 1548 1288 .config_port = icom_config_port, 1549 1289 }; 1550 1290 ··· 1571 1315 icom_port = &icom_adapter->port_info[i]; 1572 1316 icom_port->port = i; 1573 1317 icom_port->status = ICOM_PORT_ACTIVE; 1574 - icom_port->imbed_modem = ICOM_UNKNOWN; 1575 1318 } 1576 1319 } else { 1577 1320 if (subsystem_id == PCI_DEVICE_ID_IBM_ICOM_FOUR_PORT_MODEL) { ··· 1581 1326 1582 1327 icom_port->port = i; 1583 1328 icom_port->status = ICOM_PORT_ACTIVE; 1584 - icom_port->imbed_modem = ICOM_IMBED_MODEM; 1585 1329 } 1586 1330 } else { 1587 1331 icom_adapter->numb_ports = 4; 1588 1332 1589 1333 icom_adapter->port_info[0].port = 0; 1590 1334 icom_adapter->port_info[0].status = ICOM_PORT_ACTIVE; 1591 - 1592 - if (subsystem_id == 1593 - PCI_DEVICE_ID_IBM_ICOM_V2_ONE_PORT_RVX_ONE_PORT_MDM) { 1594 - icom_adapter->port_info[0].imbed_modem = ICOM_IMBED_MODEM; 1595 - } else { 1596 - icom_adapter->port_info[0].imbed_modem = ICOM_RVX; 1597 - } 1598 - 1599 1335 icom_adapter->port_info[1].status = ICOM_PORT_OFF; 1600 - 1601 1336 icom_adapter->port_info[2].port = 2; 1602 1337 icom_adapter->port_info[2].status = ICOM_PORT_ACTIVE; 1603 - icom_adapter->port_info[2].imbed_modem = ICOM_RVX; 1604 1338 icom_adapter->port_info[3].status = ICOM_PORT_OFF; 1605 1339 } 1606 1340 } ··· 1645 1401 int adapter_count = 0; 1646 1402 struct icom_adapter *icom_adapter; 1647 1403 struct icom_adapter *cur_adapter_entry; 1648 - struct list_head *tmp; 1649 1404 1650 1405 icom_adapter = kzalloc(sizeof(struct icom_adapter), GFP_KERNEL); 1651 1406 ··· 1652 1409 return -ENOMEM; 1653 1410 } 1654 1411 1655 - list_for_each(tmp, &icom_adapter_head) { 1656 - cur_adapter_entry = 1657 - list_entry(tmp, struct icom_adapter, 1658 - icom_adapter_entry); 1412 + list_for_each_entry(cur_adapter_entry, &icom_adapter_head, 1413 + icom_adapter_entry) { 1659 1414 if (cur_adapter_entry->index != adapter_count) { 1660 1415 break; 1661 1416 } ··· 1661 1420 } 1662 1421 1663 1422 icom_adapter->index = adapter_count; 1664 - list_add_tail(&icom_adapter->icom_adapter_entry, tmp); 1423 + list_add_tail(&icom_adapter->icom_adapter_entry, 1424 + &cur_adapter_entry->icom_adapter_entry); 1665 1425 1666 1426 *icom_adapter_ref = icom_adapter; 1667 1427 return 0; ··· 1674 1432 kfree(icom_adapter); 1675 1433 } 1676 1434 1677 - static void icom_remove_adapter(struct icom_adapter *icom_adapter) 1435 + static void icom_kref_release(struct kref *kref) 1678 1436 { 1437 + struct icom_adapter *icom_adapter = container_of(kref, 1438 + struct icom_adapter, kref); 1679 1439 struct icom_port *icom_port; 1680 1440 int index; 1681 1441 ··· 1710 1466 icom_free_adapter(icom_adapter); 1711 1467 } 1712 1468 1713 - static void icom_kref_release(struct kref *kref) 1714 - { 1715 - struct icom_adapter *icom_adapter; 1716 - 1717 - icom_adapter = to_icom_adapter(kref); 1718 - icom_remove_adapter(icom_adapter); 1719 - } 1720 - 1721 1469 static int icom_probe(struct pci_dev *dev, 1722 1470 const struct pci_device_id *ent) 1723 1471 { ··· 1737 1501 retval = pci_read_config_dword(dev, PCI_COMMAND, &command_reg); 1738 1502 if (retval) { 1739 1503 dev_err(&dev->dev, "PCI Config read FAILED\n"); 1740 - return retval; 1504 + goto probe_exit0; 1741 1505 } 1742 1506 1743 1507 pci_write_config_dword(dev, PCI_COMMAND, ··· 1825 1589 static void icom_remove(struct pci_dev *dev) 1826 1590 { 1827 1591 struct icom_adapter *icom_adapter; 1828 - struct list_head *tmp; 1829 1592 1830 - list_for_each(tmp, &icom_adapter_head) { 1831 - icom_adapter = list_entry(tmp, struct icom_adapter, 1832 - icom_adapter_entry); 1593 + list_for_each_entry(icom_adapter, &icom_adapter_head, 1594 + icom_adapter_entry) { 1833 1595 if (icom_adapter->pci_dev == dev) { 1834 1596 kref_put(&icom_adapter->kref, icom_kref_release); 1835 1597 return;
-274
drivers/tty/serial/icom.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0+ */ 2 - /* 3 - * icom.h 4 - * 5 - * Copyright (C) 2001 Michael Anderson, IBM Corporation 6 - * 7 - * Serial device driver include file. 8 - */ 9 - 10 - #include <linux/serial_core.h> 11 - 12 - #define BAUD_TABLE_LIMIT ((sizeof(icom_acfg_baud)/sizeof(int)) - 1) 13 - static int icom_acfg_baud[] = { 14 - 300, 15 - 600, 16 - 900, 17 - 1200, 18 - 1800, 19 - 2400, 20 - 3600, 21 - 4800, 22 - 7200, 23 - 9600, 24 - 14400, 25 - 19200, 26 - 28800, 27 - 38400, 28 - 57600, 29 - 76800, 30 - 115200, 31 - 153600, 32 - 230400, 33 - 307200, 34 - 460800, 35 - }; 36 - 37 - struct icom_regs { 38 - u32 control; /* Adapter Control Register */ 39 - u32 interrupt; /* Adapter Interrupt Register */ 40 - u32 int_mask; /* Adapter Interrupt Mask Reg */ 41 - u32 int_pri; /* Adapter Interrupt Priority r */ 42 - u32 int_reg_b; /* Adapter non-masked Interrupt */ 43 - u32 resvd01; 44 - u32 resvd02; 45 - u32 resvd03; 46 - u32 control_2; /* Adapter Control Register 2 */ 47 - u32 interrupt_2; /* Adapter Interrupt Register 2 */ 48 - u32 int_mask_2; /* Adapter Interrupt Mask 2 */ 49 - u32 int_pri_2; /* Adapter Interrupt Prior 2 */ 50 - u32 int_reg_2b; /* Adapter non-masked 2 */ 51 - }; 52 - 53 - struct func_dram { 54 - u32 reserved[108]; /* 0-1B0 reserved by personality code */ 55 - u32 RcvStatusAddr; /* 1B0-1B3 Status Address for Next rcv */ 56 - u8 RcvStnAddr; /* 1B4 Receive Station Addr */ 57 - u8 IdleState; /* 1B5 Idle State */ 58 - u8 IdleMonitor; /* 1B6 Idle Monitor */ 59 - u8 FlagFillIdleTimer; /* 1B7 Flag Fill Idle Timer */ 60 - u32 XmitStatusAddr; /* 1B8-1BB Transmit Status Address */ 61 - u8 StartXmitCmd; /* 1BC Start Xmit Command */ 62 - u8 HDLCConfigReg; /* 1BD Reserved */ 63 - u8 CauseCode; /* 1BE Cause code for fatal error */ 64 - u8 xchar; /* 1BF High priority send */ 65 - u32 reserved3; /* 1C0-1C3 Reserved */ 66 - u8 PrevCmdReg; /* 1C4 Reserved */ 67 - u8 CmdReg; /* 1C5 Command Register */ 68 - u8 async_config2; /* 1C6 Async Config Byte 2 */ 69 - u8 async_config3; /* 1C7 Async Config Byte 3 */ 70 - u8 dce_resvd[20]; /* 1C8-1DB DCE Rsvd */ 71 - u8 dce_resvd21; /* 1DC DCE Rsvd (21st byte */ 72 - u8 misc_flags; /* 1DD misc flags */ 73 - #define V2_HARDWARE 0x40 74 - #define ICOM_HDW_ACTIVE 0x01 75 - u8 call_length; /* 1DE Phone #/CFI buff ln */ 76 - u8 call_length2; /* 1DF Upper byte (unused) */ 77 - u32 call_addr; /* 1E0-1E3 Phn #/CFI buff addr */ 78 - u16 timer_value; /* 1E4-1E5 general timer value */ 79 - u8 timer_command; /* 1E6 general timer cmd */ 80 - u8 dce_command; /* 1E7 dce command reg */ 81 - u8 dce_cmd_status; /* 1E8 dce command stat */ 82 - u8 x21_r1_ioff; /* 1E9 dce ready counter */ 83 - u8 x21_r0_ioff; /* 1EA dce not ready ctr */ 84 - u8 x21_ralt_ioff; /* 1EB dce CNR counter */ 85 - u8 x21_r1_ion; /* 1EC dce ready I on ctr */ 86 - u8 rsvd_ier; /* 1ED Rsvd for IER (if ne */ 87 - u8 ier; /* 1EE Interrupt Enable */ 88 - u8 isr; /* 1EF Input Signal Reg */ 89 - u8 osr; /* 1F0 Output Signal Reg */ 90 - u8 reset; /* 1F1 Reset/Reload Reg */ 91 - u8 disable; /* 1F2 Disable Reg */ 92 - u8 sync; /* 1F3 Sync Reg */ 93 - u8 error_stat; /* 1F4 Error Status */ 94 - u8 cable_id; /* 1F5 Cable ID */ 95 - u8 cs_length; /* 1F6 CS Load Length */ 96 - u8 mac_length; /* 1F7 Mac Load Length */ 97 - u32 cs_load_addr; /* 1F8-1FB Call Load PCI Addr */ 98 - u32 mac_load_addr; /* 1FC-1FF Mac Load PCI Addr */ 99 - }; 100 - 101 - /* 102 - * adapter defines and structures 103 - */ 104 - #define ICOM_CONTROL_START_A 0x00000008 105 - #define ICOM_CONTROL_STOP_A 0x00000004 106 - #define ICOM_CONTROL_START_B 0x00000002 107 - #define ICOM_CONTROL_STOP_B 0x00000001 108 - #define ICOM_CONTROL_START_C 0x00000008 109 - #define ICOM_CONTROL_STOP_C 0x00000004 110 - #define ICOM_CONTROL_START_D 0x00000002 111 - #define ICOM_CONTROL_STOP_D 0x00000001 112 - #define ICOM_IRAM_OFFSET 0x1000 113 - #define ICOM_IRAM_SIZE 0x0C00 114 - #define ICOM_DCE_IRAM_OFFSET 0x0A00 115 - #define ICOM_CABLE_ID_VALID 0x01 116 - #define ICOM_CABLE_ID_MASK 0xF0 117 - #define ICOM_DISABLE 0x80 118 - #define CMD_XMIT_RCV_ENABLE 0xC0 119 - #define CMD_XMIT_ENABLE 0x40 120 - #define CMD_RCV_DISABLE 0x00 121 - #define CMD_RCV_ENABLE 0x80 122 - #define CMD_RESTART 0x01 123 - #define CMD_HOLD_XMIT 0x02 124 - #define CMD_SND_BREAK 0x04 125 - #define RS232_CABLE 0x06 126 - #define V24_CABLE 0x0E 127 - #define V35_CABLE 0x0C 128 - #define V36_CABLE 0x02 129 - #define NO_CABLE 0x00 130 - #define START_DOWNLOAD 0x80 131 - #define ICOM_INT_MASK_PRC_A 0x00003FFF 132 - #define ICOM_INT_MASK_PRC_B 0x3FFF0000 133 - #define ICOM_INT_MASK_PRC_C 0x00003FFF 134 - #define ICOM_INT_MASK_PRC_D 0x3FFF0000 135 - #define INT_RCV_COMPLETED 0x1000 136 - #define INT_XMIT_COMPLETED 0x2000 137 - #define INT_IDLE_DETECT 0x0800 138 - #define INT_RCV_DISABLED 0x0400 139 - #define INT_XMIT_DISABLED 0x0200 140 - #define INT_RCV_XMIT_SHUTDOWN 0x0100 141 - #define INT_FATAL_ERROR 0x0080 142 - #define INT_CABLE_PULL 0x0020 143 - #define INT_SIGNAL_CHANGE 0x0010 144 - #define HDLC_PPP_PURE_ASYNC 0x02 145 - #define HDLC_FF_FILL 0x00 146 - #define HDLC_HDW_FLOW 0x01 147 - #define START_XMIT 0x80 148 - #define ICOM_ACFG_DRIVE1 0x20 149 - #define ICOM_ACFG_NO_PARITY 0x00 150 - #define ICOM_ACFG_PARITY_ENAB 0x02 151 - #define ICOM_ACFG_PARITY_ODD 0x01 152 - #define ICOM_ACFG_8BPC 0x00 153 - #define ICOM_ACFG_7BPC 0x04 154 - #define ICOM_ACFG_6BPC 0x08 155 - #define ICOM_ACFG_5BPC 0x0C 156 - #define ICOM_ACFG_1STOP_BIT 0x00 157 - #define ICOM_ACFG_2STOP_BIT 0x10 158 - #define ICOM_DTR 0x80 159 - #define ICOM_RTS 0x40 160 - #define ICOM_RI 0x08 161 - #define ICOM_DSR 0x80 162 - #define ICOM_DCD 0x20 163 - #define ICOM_CTS 0x40 164 - 165 - #define NUM_XBUFFS 1 166 - #define NUM_RBUFFS 2 167 - #define RCV_BUFF_SZ 0x0200 168 - #define XMIT_BUFF_SZ 0x1000 169 - struct statusArea { 170 - /**********************************************/ 171 - /* Transmit Status Area */ 172 - /**********************************************/ 173 - struct xmit_status_area{ 174 - u32 leNext; /* Next entry in Little Endian on Adapter */ 175 - u32 leNextASD; 176 - u32 leBuffer; /* Buffer for entry in LE for Adapter */ 177 - u16 leLengthASD; 178 - u16 leOffsetASD; 179 - u16 leLength; /* Length of data in segment */ 180 - u16 flags; 181 - #define SA_FLAGS_DONE 0x0080 /* Done with Segment */ 182 - #define SA_FLAGS_CONTINUED 0x8000 /* More Segments */ 183 - #define SA_FLAGS_IDLE 0x4000 /* Mark IDLE after frm */ 184 - #define SA_FLAGS_READY_TO_XMIT 0x0800 185 - #define SA_FLAGS_STAT_MASK 0x007F 186 - } xmit[NUM_XBUFFS]; 187 - 188 - /**********************************************/ 189 - /* Receive Status Area */ 190 - /**********************************************/ 191 - struct { 192 - u32 leNext; /* Next entry in Little Endian on Adapter */ 193 - u32 leNextASD; 194 - u32 leBuffer; /* Buffer for entry in LE for Adapter */ 195 - u16 WorkingLength; /* size of segment */ 196 - u16 reserv01; 197 - u16 leLength; /* Length of data in segment */ 198 - u16 flags; 199 - #define SA_FL_RCV_DONE 0x0010 /* Data ready */ 200 - #define SA_FLAGS_OVERRUN 0x0040 201 - #define SA_FLAGS_PARITY_ERROR 0x0080 202 - #define SA_FLAGS_FRAME_ERROR 0x0001 203 - #define SA_FLAGS_FRAME_TRUNC 0x0002 204 - #define SA_FLAGS_BREAK_DET 0x0004 /* set conditionally by device driver, not hardware */ 205 - #define SA_FLAGS_RCV_MASK 0xFFE6 206 - } rcv[NUM_RBUFFS]; 207 - }; 208 - 209 - struct icom_adapter; 210 - 211 - 212 - #define ICOM_MAJOR 243 213 - #define ICOM_MINOR_START 0 214 - 215 - struct icom_port { 216 - struct uart_port uart_port; 217 - u8 imbed_modem; 218 - #define ICOM_UNKNOWN 1 219 - #define ICOM_RVX 2 220 - #define ICOM_IMBED_MODEM 3 221 - unsigned char cable_id; 222 - unsigned char read_status_mask; 223 - unsigned char ignore_status_mask; 224 - void __iomem * int_reg; 225 - struct icom_regs __iomem *global_reg; 226 - struct func_dram __iomem *dram; 227 - int port; 228 - struct statusArea *statStg; 229 - dma_addr_t statStg_pci; 230 - u32 *xmitRestart; 231 - dma_addr_t xmitRestart_pci; 232 - unsigned char *xmit_buf; 233 - dma_addr_t xmit_buf_pci; 234 - unsigned char *recv_buf; 235 - dma_addr_t recv_buf_pci; 236 - int next_rcv; 237 - int put_length; 238 - int status; 239 - #define ICOM_PORT_ACTIVE 1 /* Port exists. */ 240 - #define ICOM_PORT_OFF 0 /* Port does not exist. */ 241 - int load_in_progress; 242 - struct icom_adapter *adapter; 243 - }; 244 - 245 - struct icom_adapter { 246 - void __iomem * base_addr; 247 - unsigned long base_addr_pci; 248 - struct pci_dev *pci_dev; 249 - struct icom_port port_info[4]; 250 - int index; 251 - int version; 252 - #define ADAPTER_V1 0x0001 253 - #define ADAPTER_V2 0x0002 254 - u32 subsystem_id; 255 - #define FOUR_PORT_MODEL 0x0252 256 - #define V2_TWO_PORTS_RVX 0x021A 257 - #define V2_ONE_PORT_RVX_ONE_PORT_IMBED_MDM 0x0251 258 - int numb_ports; 259 - struct list_head icom_adapter_entry; 260 - struct kref kref; 261 - }; 262 - 263 - /* prototype */ 264 - extern void iCom_sercons_init(void); 265 - 266 - struct lookup_proc_table { 267 - u32 __iomem *global_control_reg; 268 - unsigned long processor_id; 269 - }; 270 - 271 - struct lookup_int_table { 272 - u32 __iomem *global_int_mask; 273 - unsigned long processor_id; 274 - };
-2
drivers/tty/serial/imx.c
··· 1937 1937 rs485conf->flags & SER_RS485_RX_DURING_TX) 1938 1938 imx_uart_start_rx(port); 1939 1939 1940 - port->rs485 = *rs485conf; 1941 - 1942 1940 return 0; 1943 1941 } 1944 1942
+1 -7
drivers/tty/serial/jsm/jsm_cls.c
··· 689 689 /* 690 690 * If baud rate is zero, flush queues, and set mval to drop DTR. 691 691 */ 692 - if ((ch->ch_c_cflag & (CBAUD)) == 0) { 692 + if ((ch->ch_c_cflag & CBAUD) == B0) { 693 693 ch->ch_r_head = 0; 694 694 ch->ch_r_tail = 0; 695 695 ch->ch_e_head = 0; ··· 723 723 if (!(ch->ch_c_cflag & PARODD)) 724 724 lcr |= UART_LCR_EPAR; 725 725 726 - /* 727 - * Not all platforms support mark/space parity, 728 - * so this will hide behind an ifdef. 729 - */ 730 - #ifdef CMSPAR 731 726 if (ch->ch_c_cflag & CMSPAR) 732 727 lcr |= UART_LCR_SPAR; 733 - #endif 734 728 735 729 if (ch->ch_c_cflag & CSTOPB) 736 730 lcr |= UART_LCR_STOP;
+1 -7
drivers/tty/serial/jsm/jsm_neo.c
··· 938 938 /* 939 939 * If baud rate is zero, flush queues, and set mval to drop DTR. 940 940 */ 941 - if ((ch->ch_c_cflag & (CBAUD)) == 0) { 941 + if ((ch->ch_c_cflag & CBAUD) == B0) { 942 942 ch->ch_r_head = ch->ch_r_tail = 0; 943 943 ch->ch_e_head = ch->ch_e_tail = 0; 944 944 ··· 997 997 if (!(ch->ch_c_cflag & PARODD)) 998 998 lcr |= UART_LCR_EPAR; 999 999 1000 - /* 1001 - * Not all platforms support mark/space parity, 1002 - * so this will hide behind an ifdef. 1003 - */ 1004 - #ifdef CMSPAR 1005 1000 if (ch->ch_c_cflag & CMSPAR) 1006 1001 lcr |= UART_LCR_SPAR; 1007 - #endif 1008 1002 1009 1003 if (ch->ch_c_cflag & CSTOPB) 1010 1004 lcr |= UART_LCR_STOP;
-1
drivers/tty/serial/max310x.c
··· 1037 1037 1038 1038 rs485->flags &= SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX | 1039 1039 SER_RS485_ENABLED; 1040 - memset(rs485->padding, 0, sizeof(rs485->padding)); 1041 1040 port->rs485 = *rs485; 1042 1041 1043 1042 schedule_work(&one->rs_work);
-1
drivers/tty/serial/men_z135_uart.c
··· 833 833 uart->port.iotype = UPIO_MEM; 834 834 uart->port.ops = &men_z135_ops; 835 835 uart->port.irq = mcb_get_irq(mdev); 836 - uart->port.iotype = UPIO_MEM; 837 836 uart->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP; 838 837 uart->port.line = line++; 839 838 uart->port.dev = dev;
+37 -3
drivers/tty/serial/meson_uart.c
··· 68 68 #define AML_UART_BAUD_MASK 0x7fffff 69 69 #define AML_UART_BAUD_USE BIT(23) 70 70 #define AML_UART_BAUD_XTAL BIT(24) 71 + #define AML_UART_BAUD_XTAL_DIV2 BIT(27) 71 72 72 73 #define AML_UART_PORT_NUM 12 73 74 #define AML_UART_PORT_OFFSET 6 ··· 80 79 static struct uart_driver meson_uart_driver; 81 80 82 81 static struct uart_port *meson_ports[AML_UART_PORT_NUM]; 82 + 83 + struct meson_uart_data { 84 + bool has_xtal_div2; 85 + }; 83 86 84 87 static void meson_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 85 88 { ··· 258 253 return (port->type == PORT_MESON) ? "meson_uart" : NULL; 259 254 } 260 255 256 + /* 257 + * This function is called only from probe() using a temporary io mapping 258 + * in order to perform a reset before setting up the device. Since the 259 + * temporarily mapped region was successfully requested, there can be no 260 + * console on this port at this time. Hence it is not necessary for this 261 + * function to acquire the port->lock. (Since there is no console on this 262 + * port at this time, the port->lock is not initialized yet.) 263 + */ 261 264 static void meson_uart_reset(struct uart_port *port) 262 265 { 263 266 u32 val; ··· 280 267 281 268 static int meson_uart_startup(struct uart_port *port) 282 269 { 270 + unsigned long flags; 283 271 u32 val; 284 272 int ret = 0; 273 + 274 + spin_lock_irqsave(&port->lock, flags); 285 275 286 276 val = readl(port->membase + AML_UART_CONTROL); 287 277 val |= AML_UART_CLEAR_ERR; ··· 301 285 val = (AML_UART_RECV_IRQ(1) | AML_UART_XMIT_IRQ(port->fifosize / 2)); 302 286 writel(val, port->membase + AML_UART_MISC); 303 287 288 + spin_unlock_irqrestore(&port->lock, flags); 289 + 304 290 ret = request_irq(port->irq, meson_uart_interrupt, 0, 305 291 port->name, port); 306 292 ··· 311 293 312 294 static void meson_uart_change_speed(struct uart_port *port, unsigned long baud) 313 295 { 314 - u32 val; 296 + const struct meson_uart_data *private_data = port->private_data; 297 + u32 val = 0; 315 298 316 299 while (!meson_uart_tx_empty(port)) 317 300 cpu_relax(); 318 301 319 302 if (port->uartclk == 24000000) { 320 - val = ((port->uartclk / 3) / baud) - 1; 303 + unsigned int xtal_div = 3; 304 + 305 + if (private_data && private_data->has_xtal_div2) { 306 + xtal_div = 2; 307 + val |= AML_UART_BAUD_XTAL_DIV2; 308 + } 309 + val |= DIV_ROUND_CLOSEST(port->uartclk / xtal_div, baud) - 1; 321 310 val |= AML_UART_BAUD_XTAL; 322 311 } else { 323 - val = ((port->uartclk * 10 / (baud * 4) + 5) / 10) - 1; 312 + val = DIV_ROUND_CLOSEST(port->uartclk / 4, baud) - 1; 324 313 } 325 314 val |= AML_UART_BAUD_USE; 326 315 writel(val, port->membase + AML_UART_REG5); ··· 774 749 port->x_char = 0; 775 750 port->ops = &meson_uart_ops; 776 751 port->fifosize = fifosize; 752 + port->private_data = (void *)device_get_match_data(&pdev->dev); 777 753 778 754 meson_ports[pdev->id] = port; 779 755 platform_set_drvdata(pdev, port); ··· 803 777 return 0; 804 778 } 805 779 780 + static struct meson_uart_data s4_uart_data = { 781 + .has_xtal_div2 = true, 782 + }; 783 + 806 784 static const struct of_device_id meson_uart_dt_match[] = { 807 785 { .compatible = "amlogic,meson6-uart" }, 808 786 { .compatible = "amlogic,meson8-uart" }, 809 787 { .compatible = "amlogic,meson8b-uart" }, 810 788 { .compatible = "amlogic,meson-gx-uart" }, 789 + { 790 + .compatible = "amlogic,meson-s4-uart", 791 + .data = (void *)&s4_uart_data, 792 + }, 811 793 { /* sentinel */ }, 812 794 }; 813 795 MODULE_DEVICE_TABLE(of, meson_uart_dt_match);
+2 -3
drivers/tty/serial/mpc52xx_uart.c
··· 38 38 #include <linux/delay.h> 39 39 #include <linux/io.h> 40 40 #include <linux/of.h> 41 + #include <linux/of_address.h> 42 + #include <linux/of_irq.h> 41 43 #include <linux/of_platform.h> 42 44 #include <linux/clk.h> 43 45 ··· 756 754 port->irqflags = IRQF_SHARED; 757 755 port->irq = psc_fifoc_irq; 758 756 } 759 - #endif 760 - 761 - #ifdef CONFIG_PPC_MPC512x 762 757 763 758 #define PSC_5125(port) ((struct mpc5125_psc __iomem *)((port)->membase)) 764 759 #define FIFO_5125(port) ((struct mpc512x_psc_fifo __iomem *)(PSC_5125(port)+1))
+5
drivers/tty/serial/msm_serial.c
··· 1599 1599 static void __msm_console_write(struct uart_port *port, const char *s, 1600 1600 unsigned int count, bool is_uartdm) 1601 1601 { 1602 + unsigned long flags; 1602 1603 int i; 1603 1604 int num_newlines = 0; 1604 1605 bool replaced = false; ··· 1616 1615 if (s[i] == '\n') 1617 1616 num_newlines++; 1618 1617 count += num_newlines; 1618 + 1619 + local_irq_save(flags); 1619 1620 1620 1621 if (port->sysrq) 1621 1622 locked = 0; ··· 1664 1661 1665 1662 if (locked) 1666 1663 spin_unlock(&port->lock); 1664 + 1665 + local_irq_restore(flags); 1667 1666 } 1668 1667 1669 1668 static void msm_console_write(struct console *co, const char *s,
+3 -10
drivers/tty/serial/omap-serial.c
··· 1336 1336 up->ier = 0; 1337 1337 serial_out(up, UART_IER, 0); 1338 1338 1339 - /* Clamp the delays to [0, 100ms] */ 1340 - rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U); 1341 - rs485->delay_rts_after_send = min(rs485->delay_rts_after_send, 100U); 1342 - 1343 - /* store new config */ 1344 - port->rs485 = *rs485; 1345 - 1346 1339 if (up->rts_gpiod) { 1347 1340 /* enable / disable rts */ 1348 - val = (port->rs485.flags & SER_RS485_ENABLED) ? 1341 + val = (rs485->flags & SER_RS485_ENABLED) ? 1349 1342 SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND; 1350 - val = (port->rs485.flags & val) ? 1 : 0; 1343 + val = (rs485->flags & val) ? 1 : 0; 1351 1344 gpiod_set_value(up->rts_gpiod, val); 1352 1345 } 1353 1346 ··· 1351 1358 /* If RS-485 is disabled, make sure the THR interrupt is fired when 1352 1359 * TX FIFO is below the trigger level. 1353 1360 */ 1354 - if (!(port->rs485.flags & SER_RS485_ENABLED) && 1361 + if (!(rs485->flags & SER_RS485_ENABLED) && 1355 1362 (up->scr & OMAP_UART_SCR_TX_EMPTY)) { 1356 1363 up->scr &= ~OMAP_UART_SCR_TX_EMPTY; 1357 1364 serial_out(up, UART_OMAP_SCR, up->scr);
+4 -3
drivers/tty/serial/owl-uart.c
··· 184 184 struct circ_buf *xmit = &port->state->xmit; 185 185 unsigned int ch; 186 186 187 - if (uart_tx_stopped(port)) 188 - return; 189 - 190 187 if (port->x_char) { 191 188 while (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)) 192 189 cpu_relax(); ··· 191 194 port->icount.tx++; 192 195 port->x_char = 0; 193 196 } 197 + 198 + if (uart_tx_stopped(port)) 199 + return; 194 200 195 201 while (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)) { 196 202 if (uart_circ_empty(xmit)) ··· 731 731 owl_port->port.uartclk = clk_get_rate(owl_port->clk); 732 732 if (owl_port->port.uartclk == 0) { 733 733 dev_err(&pdev->dev, "clock rate is zero\n"); 734 + clk_disable_unprepare(owl_port->clk); 734 735 return -EINVAL; 735 736 } 736 737 owl_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_LOW_LATENCY;
+12 -65
drivers/tty/serial/pch_uart.c
··· 550 550 return (u8)msr; 551 551 } 552 552 553 - static void pch_uart_hal_write(struct eg20t_port *priv, 554 - const unsigned char *buf, int tx_size) 555 - { 556 - int i; 557 - unsigned int thr; 558 - 559 - for (i = 0; i < tx_size;) { 560 - thr = buf[i++]; 561 - iowrite8(thr, priv->membase + PCH_UART_THR); 562 - } 563 - } 564 - 565 553 static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf, 566 554 int rx_size) 567 555 { ··· 610 622 tty_flip_buffer_push(tport); 611 623 612 624 return 0; 613 - } 614 - 615 - static int pop_tx_x(struct eg20t_port *priv, unsigned char *buf) 616 - { 617 - int ret = 0; 618 - struct uart_port *port = &priv->port; 619 - 620 - if (port->x_char) { 621 - dev_dbg(priv->port.dev, "%s:X character send %02x (%lu)\n", 622 - __func__, port->x_char, jiffies); 623 - buf[0] = port->x_char; 624 - port->x_char = 0; 625 - ret = 1; 626 - } 627 - 628 - return ret; 629 625 } 630 626 631 627 static int dma_push_rx(struct eg20t_port *priv, int size) ··· 757 785 pch_uart_hal_enable_interrupt(priv, PCH_UART_HAL_TX_INT); 758 786 } 759 787 760 - static int pop_tx(struct eg20t_port *priv, int size) 761 - { 762 - int count = 0; 763 - struct uart_port *port = &priv->port; 764 - struct circ_buf *xmit = &port->state->xmit; 765 - 766 - if (uart_tx_stopped(port) || uart_circ_empty(xmit) || count >= size) 767 - goto pop_tx_end; 768 - 769 - do { 770 - int cnt_to_end = 771 - CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 772 - int sz = min(size - count, cnt_to_end); 773 - pch_uart_hal_write(priv, &xmit->buf[xmit->tail], sz); 774 - xmit->tail = (xmit->tail + sz) & (UART_XMIT_SIZE - 1); 775 - count += sz; 776 - } while (!uart_circ_empty(xmit) && count < size); 777 - 778 - pop_tx_end: 779 - dev_dbg(priv->port.dev, "%d characters. Remained %d characters.(%lu)\n", 780 - count, size - count, jiffies); 781 - 782 - return count; 783 - } 784 - 785 788 static int handle_rx_to(struct eg20t_port *priv) 786 789 { 787 790 struct pch_uart_buffer *buf; ··· 822 875 struct uart_port *port = &priv->port; 823 876 struct circ_buf *xmit = &port->state->xmit; 824 877 int fifo_size; 825 - int tx_size; 826 - int size; 827 878 int tx_empty; 828 879 829 880 if (!priv->start_tx) { ··· 834 889 835 890 fifo_size = max(priv->fifo_size, 1); 836 891 tx_empty = 1; 837 - if (pop_tx_x(priv, xmit->buf)) { 838 - pch_uart_hal_write(priv, xmit->buf, 1); 892 + if (port->x_char) { 893 + iowrite8(port->x_char, priv->membase + PCH_UART_THR); 839 894 port->icount.tx++; 895 + port->x_char = 0; 840 896 tx_empty = 0; 841 897 fifo_size--; 842 898 } 843 - size = min(xmit->head - xmit->tail, fifo_size); 844 - if (size < 0) 845 - size = fifo_size; 846 899 847 - tx_size = pop_tx(priv, size); 848 - if (tx_size > 0) { 849 - port->icount.tx += tx_size; 900 + while (!uart_tx_stopped(port) && !uart_circ_empty(xmit) && fifo_size) { 901 + iowrite8(xmit->buf[xmit->tail], priv->membase + PCH_UART_THR); 902 + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 903 + port->icount.tx++; 904 + fifo_size--; 850 905 tx_empty = 0; 851 906 } 852 907 ··· 891 946 } 892 947 893 948 fifo_size = max(priv->fifo_size, 1); 894 - if (pop_tx_x(priv, xmit->buf)) { 895 - pch_uart_hal_write(priv, xmit->buf, 1); 949 + 950 + if (port->x_char) { 951 + iowrite8(port->x_char, priv->membase + PCH_UART_THR); 896 952 port->icount.tx++; 953 + port->x_char = 0; 897 954 fifo_size--; 898 955 } 899 956
+117 -44
drivers/tty/serial/pic32_uart.c
··· 25 25 #include <linux/delay.h> 26 26 27 27 #include <asm/mach-pic32/pic32.h> 28 - #include "pic32_uart.h" 29 28 30 29 /* UART name and device definitions */ 31 30 #define PIC32_DEV_NAME "pic32-uart" 32 31 #define PIC32_MAX_UARTS 6 33 32 #define PIC32_SDEV_NAME "ttyPIC" 33 + 34 + #define PIC32_UART_DFLT_BRATE 9600 35 + #define PIC32_UART_TX_FIFO_DEPTH 8 36 + #define PIC32_UART_RX_FIFO_DEPTH 8 37 + 38 + #define PIC32_UART_MODE 0x00 39 + #define PIC32_UART_STA 0x10 40 + #define PIC32_UART_TX 0x20 41 + #define PIC32_UART_RX 0x30 42 + #define PIC32_UART_BRG 0x40 43 + 44 + /* struct pic32_sport - pic32 serial port descriptor 45 + * @port: uart port descriptor 46 + * @idx: port index 47 + * @irq_fault: virtual fault interrupt number 48 + * @irq_fault_name: irq fault name 49 + * @irq_rx: virtual rx interrupt number 50 + * @irq_rx_name: irq rx name 51 + * @irq_tx: virtual tx interrupt number 52 + * @irq_tx_name: irq tx name 53 + * @cts_gpio: clear to send gpio 54 + * @dev: device descriptor 55 + **/ 56 + struct pic32_sport { 57 + struct uart_port port; 58 + int idx; 59 + 60 + int irq_fault; 61 + const char *irq_fault_name; 62 + int irq_rx; 63 + const char *irq_rx_name; 64 + int irq_tx; 65 + const char *irq_tx_name; 66 + bool enable_tx_irq; 67 + 68 + bool hw_flow_ctrl; 69 + int cts_gpio; 70 + 71 + struct clk *clk; 72 + 73 + struct device *dev; 74 + }; 75 + 76 + static inline struct pic32_sport *to_pic32_sport(struct uart_port *port) 77 + { 78 + return container_of(port, struct pic32_sport, port); 79 + } 80 + 81 + static inline void pic32_uart_writel(struct pic32_sport *sport, 82 + u32 reg, u32 val) 83 + { 84 + __raw_writel(val, sport->port.membase + reg); 85 + } 86 + 87 + static inline u32 pic32_uart_readl(struct pic32_sport *sport, u32 reg) 88 + { 89 + return __raw_readl(sport->port.membase + reg); 90 + } 91 + 92 + /* pic32 uart mode register bits */ 93 + #define PIC32_UART_MODE_ON BIT(15) 94 + #define PIC32_UART_MODE_FRZ BIT(14) 95 + #define PIC32_UART_MODE_SIDL BIT(13) 96 + #define PIC32_UART_MODE_IREN BIT(12) 97 + #define PIC32_UART_MODE_RTSMD BIT(11) 98 + #define PIC32_UART_MODE_RESV1 BIT(10) 99 + #define PIC32_UART_MODE_UEN1 BIT(9) 100 + #define PIC32_UART_MODE_UEN0 BIT(8) 101 + #define PIC32_UART_MODE_WAKE BIT(7) 102 + #define PIC32_UART_MODE_LPBK BIT(6) 103 + #define PIC32_UART_MODE_ABAUD BIT(5) 104 + #define PIC32_UART_MODE_RXINV BIT(4) 105 + #define PIC32_UART_MODE_BRGH BIT(3) 106 + #define PIC32_UART_MODE_PDSEL1 BIT(2) 107 + #define PIC32_UART_MODE_PDSEL0 BIT(1) 108 + #define PIC32_UART_MODE_STSEL BIT(0) 109 + 110 + /* pic32 uart status register bits */ 111 + #define PIC32_UART_STA_UTXISEL1 BIT(15) 112 + #define PIC32_UART_STA_UTXISEL0 BIT(14) 113 + #define PIC32_UART_STA_UTXINV BIT(13) 114 + #define PIC32_UART_STA_URXEN BIT(12) 115 + #define PIC32_UART_STA_UTXBRK BIT(11) 116 + #define PIC32_UART_STA_UTXEN BIT(10) 117 + #define PIC32_UART_STA_UTXBF BIT(9) 118 + #define PIC32_UART_STA_TRMT BIT(8) 119 + #define PIC32_UART_STA_URXISEL1 BIT(7) 120 + #define PIC32_UART_STA_URXISEL0 BIT(6) 121 + #define PIC32_UART_STA_ADDEN BIT(5) 122 + #define PIC32_UART_STA_RIDLE BIT(4) 123 + #define PIC32_UART_STA_PERR BIT(3) 124 + #define PIC32_UART_STA_FERR BIT(2) 125 + #define PIC32_UART_STA_OERR BIT(1) 126 + #define PIC32_UART_STA_URXDA BIT(0) 34 127 35 128 /* pic32_sport pointer for console use */ 36 129 static struct pic32_sport *pic32_sports[PIC32_MAX_UARTS]; ··· 133 40 /* wait for tx empty, otherwise chars will be lost or corrupted */ 134 41 while (!(pic32_uart_readl(sport, PIC32_UART_STA) & PIC32_UART_STA_TRMT)) 135 42 udelay(1); 136 - } 137 - 138 - static inline int pic32_enable_clock(struct pic32_sport *sport) 139 - { 140 - int ret = clk_prepare_enable(sport->clk); 141 - 142 - if (ret) 143 - return ret; 144 - 145 - sport->ref_clk++; 146 - return 0; 147 - } 148 - 149 - static inline void pic32_disable_clock(struct pic32_sport *sport) 150 - { 151 - sport->ref_clk--; 152 - clk_disable_unprepare(sport->clk); 153 43 } 154 44 155 45 /* serial core request to check if uart tx buffer is empty */ ··· 193 117 */ 194 118 static inline void pic32_uart_irqtxen(struct pic32_sport *sport, u8 en) 195 119 { 196 - if (en && !tx_irq_enabled(sport)) { 120 + if (en && !sport->enable_tx_irq) { 197 121 enable_irq(sport->irq_tx); 198 - tx_irq_enabled(sport) = 1; 199 - } else if (!en && tx_irq_enabled(sport)) { 122 + sport->enable_tx_irq = true; 123 + } else if (!en && sport->enable_tx_irq) { 200 124 /* use disable_irq_nosync() and not disable_irq() to avoid self 201 125 * imposed deadlock by not waiting for irq handler to end, 202 126 * since this callback is called from interrupt context. 203 127 */ 204 128 disable_irq_nosync(sport->irq_tx); 205 - tx_irq_enabled(sport) = 0; 129 + sport->enable_tx_irq = false; 206 130 } 207 131 } 208 132 ··· 471 395 472 396 local_irq_save(flags); 473 397 474 - ret = pic32_enable_clock(sport); 398 + ret = clk_prepare_enable(sport->clk); 475 399 if (ret) { 476 400 local_irq_restore(flags); 477 401 goto out_done; ··· 495 419 * For each irq request_irq() is called with interrupt disabled. 496 420 * And the irq is enabled as soon as we are ready to handle them. 497 421 */ 498 - tx_irq_enabled(sport) = 0; 422 + sport->enable_tx_irq = false; 499 423 500 424 sport->irq_fault_name = kasprintf(GFP_KERNEL, "%s%d-fault", 501 425 pic32_uart_type(port), ··· 507 431 } 508 432 irq_set_status_flags(sport->irq_fault, IRQ_NOAUTOEN); 509 433 ret = request_irq(sport->irq_fault, pic32_uart_fault_interrupt, 510 - sport->irqflags_fault, sport->irq_fault_name, port); 434 + IRQF_NO_THREAD, sport->irq_fault_name, port); 511 435 if (ret) { 512 436 dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n", 513 437 __func__, sport->irq_fault, ret, ··· 525 449 } 526 450 irq_set_status_flags(sport->irq_rx, IRQ_NOAUTOEN); 527 451 ret = request_irq(sport->irq_rx, pic32_uart_rx_interrupt, 528 - sport->irqflags_rx, sport->irq_rx_name, port); 452 + IRQF_NO_THREAD, sport->irq_rx_name, port); 529 453 if (ret) { 530 454 dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n", 531 455 __func__, sport->irq_rx, ret, ··· 543 467 } 544 468 irq_set_status_flags(sport->irq_tx, IRQ_NOAUTOEN); 545 469 ret = request_irq(sport->irq_tx, pic32_uart_tx_interrupt, 546 - sport->irqflags_tx, sport->irq_tx_name, port); 470 + IRQF_NO_THREAD, sport->irq_tx_name, port); 547 471 if (ret) { 548 472 dev_err(port->dev, "%s: request irq(%d) err! ret:%d name:%s\n", 549 473 __func__, sport->irq_tx, ret, ··· 564 488 /* enable all interrupts and eanable uart */ 565 489 pic32_uart_en_and_unmask(port); 566 490 491 + local_irq_restore(flags); 492 + 567 493 enable_irq(sport->irq_rx); 568 494 569 495 return 0; 570 496 571 497 out_t: 572 - kfree(sport->irq_tx_name); 573 498 free_irq(sport->irq_tx, port); 499 + kfree(sport->irq_tx_name); 574 500 out_r: 575 - kfree(sport->irq_rx_name); 576 501 free_irq(sport->irq_rx, port); 502 + kfree(sport->irq_rx_name); 577 503 out_f: 578 - kfree(sport->irq_fault_name); 579 504 free_irq(sport->irq_fault, port); 505 + kfree(sport->irq_fault_name); 580 506 out_done: 581 507 return ret; 582 508 } ··· 593 515 spin_lock_irqsave(&port->lock, flags); 594 516 pic32_uart_dsbl_and_mask(port); 595 517 spin_unlock_irqrestore(&port->lock, flags); 596 - pic32_disable_clock(sport); 518 + clk_disable_unprepare(sport->clk); 597 519 598 520 /* free all 3 interrupts for this UART */ 599 521 free_irq(sport->irq_fault, port); 522 + kfree(sport->irq_fault_name); 600 523 free_irq(sport->irq_tx, port); 524 + kfree(sport->irq_tx_name); 601 525 free_irq(sport->irq_rx, port); 526 + kfree(sport->irq_rx_name); 602 527 } 603 528 604 529 /* serial core request to change current uart setting */ ··· 793 712 unsigned int count) 794 713 { 795 714 struct pic32_sport *sport = pic32_sports[co->index]; 796 - struct uart_port *port = pic32_get_port(sport); 797 715 798 716 /* call uart helper to deal with \r\n */ 799 - uart_console_write(port, s, count, pic32_console_putchar); 717 + uart_console_write(&sport->port, s, count, pic32_console_putchar); 800 718 } 801 719 802 720 /* console core request to setup given console, find matching uart ··· 804 724 static int pic32_console_setup(struct console *co, char *options) 805 725 { 806 726 struct pic32_sport *sport; 807 - struct uart_port *port = NULL; 808 727 int baud = 115200; 809 728 int bits = 8; 810 729 int parity = 'n'; ··· 816 737 sport = pic32_sports[co->index]; 817 738 if (!sport) 818 739 return -ENODEV; 819 - port = pic32_get_port(sport); 820 740 821 - ret = pic32_enable_clock(sport); 741 + ret = clk_prepare_enable(sport->clk); 822 742 if (ret) 823 743 return ret; 824 744 825 745 if (options) 826 746 uart_parse_options(options, &baud, &parity, &bits, &flow); 827 747 828 - return uart_set_options(port, co, baud, parity, bits, flow); 748 + return uart_set_options(&sport->port, co, baud, parity, bits, flow); 829 749 } 830 750 831 751 static struct uart_driver pic32_uart_driver; ··· 894 816 895 817 sport->idx = uart_idx; 896 818 sport->irq_fault = irq_of_parse_and_map(np, 0); 897 - sport->irqflags_fault = IRQF_NO_THREAD; 898 819 sport->irq_rx = irq_of_parse_and_map(np, 1); 899 - sport->irqflags_rx = IRQF_NO_THREAD; 900 820 sport->irq_tx = irq_of_parse_and_map(np, 2); 901 - sport->irqflags_tx = IRQF_NO_THREAD; 902 821 sport->clk = devm_clk_get(&pdev->dev, NULL); 903 - sport->cts_gpio = -EINVAL; 904 822 sport->dev = &pdev->dev; 905 823 906 824 /* Hardware flow control: gpios ··· 924 850 925 851 pic32_sports[uart_idx] = sport; 926 852 port = &sport->port; 927 - memset(port, 0, sizeof(*port)); 928 853 port->iotype = UPIO_MEM; 929 854 port->mapbase = res_mem->start; 930 855 port->ops = &pic32_uart_ops; ··· 945 872 /* The peripheral clock has been enabled by console_setup, 946 873 * so disable it till the port is used. 947 874 */ 948 - pic32_disable_clock(sport); 875 + clk_disable_unprepare(sport->clk); 949 876 } 950 877 #endif 951 878 ··· 966 893 struct pic32_sport *sport = to_pic32_sport(port); 967 894 968 895 uart_remove_one_port(&pic32_uart_driver, port); 969 - pic32_disable_clock(sport); 896 + clk_disable_unprepare(sport->clk); 970 897 platform_set_drvdata(pdev, NULL); 971 898 pic32_sports[sport->idx] = NULL; 972 899
-125
drivers/tty/serial/pic32_uart.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0+ */ 2 - /* 3 - * PIC32 Integrated Serial Driver. 4 - * 5 - * Copyright (C) 2015 Microchip Technology, Inc. 6 - * 7 - * Authors: 8 - * Sorin-Andrei Pistirica <andrei.pistirica@microchip.com> 9 - */ 10 - #ifndef __DT_PIC32_UART_H__ 11 - #define __DT_PIC32_UART_H__ 12 - 13 - #define PIC32_UART_DFLT_BRATE (9600) 14 - #define PIC32_UART_TX_FIFO_DEPTH (8) 15 - #define PIC32_UART_RX_FIFO_DEPTH (8) 16 - 17 - #define PIC32_UART_MODE 0x00 18 - #define PIC32_UART_STA 0x10 19 - #define PIC32_UART_TX 0x20 20 - #define PIC32_UART_RX 0x30 21 - #define PIC32_UART_BRG 0x40 22 - 23 - struct pic32_console_opt { 24 - int baud; 25 - int parity; 26 - int bits; 27 - int flow; 28 - }; 29 - 30 - /* struct pic32_sport - pic32 serial port descriptor 31 - * @port: uart port descriptor 32 - * @idx: port index 33 - * @irq_fault: virtual fault interrupt number 34 - * @irqflags_fault: flags related to fault irq 35 - * @irq_fault_name: irq fault name 36 - * @irq_rx: virtual rx interrupt number 37 - * @irqflags_rx: flags related to rx irq 38 - * @irq_rx_name: irq rx name 39 - * @irq_tx: virtual tx interrupt number 40 - * @irqflags_tx: : flags related to tx irq 41 - * @irq_tx_name: irq tx name 42 - * @cts_gpio: clear to send gpio 43 - * @dev: device descriptor 44 - **/ 45 - struct pic32_sport { 46 - struct uart_port port; 47 - struct pic32_console_opt opt; 48 - int idx; 49 - 50 - int irq_fault; 51 - int irqflags_fault; 52 - const char *irq_fault_name; 53 - int irq_rx; 54 - int irqflags_rx; 55 - const char *irq_rx_name; 56 - int irq_tx; 57 - int irqflags_tx; 58 - const char *irq_tx_name; 59 - u8 enable_tx_irq; 60 - 61 - bool hw_flow_ctrl; 62 - int cts_gpio; 63 - 64 - int ref_clk; 65 - struct clk *clk; 66 - 67 - struct device *dev; 68 - }; 69 - #define to_pic32_sport(c) container_of(c, struct pic32_sport, port) 70 - #define pic32_get_port(sport) (&sport->port) 71 - #define pic32_get_opt(sport) (&sport->opt) 72 - #define tx_irq_enabled(sport) (sport->enable_tx_irq) 73 - 74 - static inline void pic32_uart_writel(struct pic32_sport *sport, 75 - u32 reg, u32 val) 76 - { 77 - struct uart_port *port = pic32_get_port(sport); 78 - 79 - __raw_writel(val, port->membase + reg); 80 - } 81 - 82 - static inline u32 pic32_uart_readl(struct pic32_sport *sport, u32 reg) 83 - { 84 - struct uart_port *port = pic32_get_port(sport); 85 - 86 - return __raw_readl(port->membase + reg); 87 - } 88 - 89 - /* pic32 uart mode register bits */ 90 - #define PIC32_UART_MODE_ON BIT(15) 91 - #define PIC32_UART_MODE_FRZ BIT(14) 92 - #define PIC32_UART_MODE_SIDL BIT(13) 93 - #define PIC32_UART_MODE_IREN BIT(12) 94 - #define PIC32_UART_MODE_RTSMD BIT(11) 95 - #define PIC32_UART_MODE_RESV1 BIT(10) 96 - #define PIC32_UART_MODE_UEN1 BIT(9) 97 - #define PIC32_UART_MODE_UEN0 BIT(8) 98 - #define PIC32_UART_MODE_WAKE BIT(7) 99 - #define PIC32_UART_MODE_LPBK BIT(6) 100 - #define PIC32_UART_MODE_ABAUD BIT(5) 101 - #define PIC32_UART_MODE_RXINV BIT(4) 102 - #define PIC32_UART_MODE_BRGH BIT(3) 103 - #define PIC32_UART_MODE_PDSEL1 BIT(2) 104 - #define PIC32_UART_MODE_PDSEL0 BIT(1) 105 - #define PIC32_UART_MODE_STSEL BIT(0) 106 - 107 - /* pic32 uart status register bits */ 108 - #define PIC32_UART_STA_UTXISEL1 BIT(15) 109 - #define PIC32_UART_STA_UTXISEL0 BIT(14) 110 - #define PIC32_UART_STA_UTXINV BIT(13) 111 - #define PIC32_UART_STA_URXEN BIT(12) 112 - #define PIC32_UART_STA_UTXBRK BIT(11) 113 - #define PIC32_UART_STA_UTXEN BIT(10) 114 - #define PIC32_UART_STA_UTXBF BIT(9) 115 - #define PIC32_UART_STA_TRMT BIT(8) 116 - #define PIC32_UART_STA_URXISEL1 BIT(7) 117 - #define PIC32_UART_STA_URXISEL0 BIT(6) 118 - #define PIC32_UART_STA_ADDEN BIT(5) 119 - #define PIC32_UART_STA_RIDLE BIT(4) 120 - #define PIC32_UART_STA_PERR BIT(3) 121 - #define PIC32_UART_STA_FERR BIT(2) 122 - #define PIC32_UART_STA_OERR BIT(1) 123 - #define PIC32_UART_STA_URXDA BIT(0) 124 - 125 - #endif /* __DT_PIC32_UART_H__ */
+2 -67
drivers/tty/serial/pmac_zilog.c
··· 24 24 */ 25 25 26 26 #undef DEBUG 27 - #undef DEBUG_HARD 28 27 #undef USE_CTRL_O_SYSRQ 29 28 30 29 #include <linux/module.h> ··· 50 51 #include <asm/irq.h> 51 52 52 53 #ifdef CONFIG_PPC_PMAC 53 - #include <asm/prom.h> 54 54 #include <asm/machdep.h> 55 55 #include <asm/pmac_feature.h> 56 56 #include <asm/dbdma.h> ··· 64 66 65 67 #include "pmac_zilog.h" 66 68 67 - /* Not yet implemented */ 68 - #undef HAS_DBDMA 69 - 70 - static char version[] __initdata = "pmac_zilog: 0.6 (Benjamin Herrenschmidt <benh@kernel.crashing.org>)"; 71 69 MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); 72 70 MODULE_DESCRIPTION("Driver for the Mac and PowerMac serial ports."); 73 71 MODULE_LICENSE("GPL"); ··· 440 446 spin_lock(&uap_a->port.lock); 441 447 r3 = read_zsreg(uap_a, R3); 442 448 443 - #ifdef DEBUG_HARD 444 - pmz_debug("irq, r3: %x\n", r3); 445 - #endif 446 449 /* Channel A */ 447 450 push = false; 448 451 if (r3 & (CHAEXT | CHATxIP | CHARxIP)) { ··· 604 613 struct uart_pmac_port *uap = to_pmz(port); 605 614 unsigned char status; 606 615 607 - pmz_debug("pmz: start_tx()\n"); 608 - 609 616 uap->flags |= PMACZILOG_FLAG_TX_ACTIVE; 610 617 uap->flags &= ~PMACZILOG_FLAG_TX_STOPPED; 611 618 ··· 625 636 struct circ_buf *xmit = &port->state->xmit; 626 637 627 638 if (uart_circ_empty(xmit)) 628 - goto out; 639 + return; 629 640 write_zsdata(uap, xmit->buf[xmit->tail]); 630 641 zssync(uap); 631 642 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); ··· 634 645 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 635 646 uart_write_wakeup(&uap->port); 636 647 } 637 - out: 638 - pmz_debug("pmz: start_tx() done.\n"); 639 648 } 640 649 641 650 /* ··· 646 659 { 647 660 struct uart_pmac_port *uap = to_pmz(port); 648 661 649 - pmz_debug("pmz: stop_rx()()\n"); 650 - 651 662 /* Disable all RX interrupts. */ 652 663 uap->curregs[R1] &= ~RxINT_MASK; 653 664 pmz_maybe_update_regs(uap); 654 - 655 - pmz_debug("pmz: stop_rx() done.\n"); 656 665 } 657 666 658 667 /* ··· 893 910 unsigned long flags; 894 911 int pwr_delay = 0; 895 912 896 - pmz_debug("pmz: startup()\n"); 897 - 898 913 uap->flags |= PMACZILOG_FLAG_IS_OPEN; 899 914 900 915 /* A console is never powered down. Else, power up and ··· 928 947 pmz_interrupt_control(uap, 1); 929 948 spin_unlock_irqrestore(&port->lock, flags); 930 949 931 - pmz_debug("pmz: startup() done.\n"); 932 - 933 950 return 0; 934 951 } 935 952 ··· 935 956 { 936 957 struct uart_pmac_port *uap = to_pmz(port); 937 958 unsigned long flags; 938 - 939 - pmz_debug("pmz: shutdown()\n"); 940 959 941 960 spin_lock_irqsave(&port->lock, flags); 942 961 ··· 964 987 pmz_set_scc_power(uap, 0); /* Shut the chip down */ 965 988 966 989 spin_unlock_irqrestore(&port->lock, flags); 967 - 968 - pmz_debug("pmz: shutdown() done.\n"); 969 990 } 970 991 971 992 /* Shared by TTY driver and serial console setup. The port lock is held ··· 1208 1233 struct uart_pmac_port *uap = to_pmz(port); 1209 1234 unsigned long baud; 1210 1235 1211 - pmz_debug("pmz: set_termios()\n"); 1212 - 1213 - memcpy(&uap->termios_cache, termios, sizeof(struct ktermios)); 1214 - 1215 1236 /* XXX Check which revs of machines actually allow 1 and 4Mb speeds 1216 1237 * on the IR dongle. Note that the IRTTY driver currently doesn't know 1217 1238 * about the FIR mode and high speed modes. So these are unused. For ··· 1241 1270 pmz_maybe_update_regs(uap); 1242 1271 } 1243 1272 uart_update_timeout(port, termios->c_cflag, baud); 1244 - 1245 - pmz_debug("pmz: set_termios() done.\n"); 1246 1273 } 1247 1274 1248 1275 /* The port lock is not held. */ ··· 1369 1400 char name[1]; 1370 1401 } *slots; 1371 1402 int len; 1372 - struct resource r_ports, r_rxdma, r_txdma; 1403 + struct resource r_ports; 1373 1404 1374 1405 /* 1375 1406 * Request & map chip registers ··· 1381 1412 1382 1413 uap->control_reg = uap->port.membase; 1383 1414 uap->data_reg = uap->control_reg + 0x10; 1384 - 1385 - /* 1386 - * Request & map DBDMA registers 1387 - */ 1388 - #ifdef HAS_DBDMA 1389 - if (of_address_to_resource(np, 1, &r_txdma) == 0 && 1390 - of_address_to_resource(np, 2, &r_rxdma) == 0) 1391 - uap->flags |= PMACZILOG_FLAG_HAS_DMA; 1392 - #else 1393 - memset(&r_txdma, 0, sizeof(struct resource)); 1394 - memset(&r_rxdma, 0, sizeof(struct resource)); 1395 - #endif 1396 - if (ZS_HAS_DMA(uap)) { 1397 - uap->tx_dma_regs = ioremap(r_txdma.start, 0x100); 1398 - if (uap->tx_dma_regs == NULL) { 1399 - uap->flags &= ~PMACZILOG_FLAG_HAS_DMA; 1400 - goto no_dma; 1401 - } 1402 - uap->rx_dma_regs = ioremap(r_rxdma.start, 0x100); 1403 - if (uap->rx_dma_regs == NULL) { 1404 - iounmap(uap->tx_dma_regs); 1405 - uap->tx_dma_regs = NULL; 1406 - uap->flags &= ~PMACZILOG_FLAG_HAS_DMA; 1407 - goto no_dma; 1408 - } 1409 - uap->tx_dma_irq = irq_of_parse_and_map(np, 1); 1410 - uap->rx_dma_irq = irq_of_parse_and_map(np, 2); 1411 - } 1412 - no_dma: 1413 1415 1414 1416 /* 1415 1417 * Detect port type ··· 1446 1506 of_device_is_compatible(np->parent->parent, "gatwick")) { 1447 1507 /* IRQs on gatwick are offset by 64 */ 1448 1508 uap->port.irq = irq_create_mapping(NULL, 64 + 15); 1449 - uap->tx_dma_irq = irq_create_mapping(NULL, 64 + 4); 1450 - uap->rx_dma_irq = irq_create_mapping(NULL, 64 + 5); 1451 1509 } 1452 1510 1453 1511 /* Setup some valid baud rate information in the register ··· 1465 1527 struct device_node *np; 1466 1528 1467 1529 np = uap->node; 1468 - iounmap(uap->rx_dma_regs); 1469 - iounmap(uap->tx_dma_regs); 1470 1530 iounmap(uap->control_reg); 1471 1531 uap->node = NULL; 1472 1532 of_node_put(np); ··· 1811 1875 static int __init init_pmz(void) 1812 1876 { 1813 1877 int rc, i; 1814 - printk(KERN_INFO "%s\n", version); 1815 1878 1816 1879 /* 1817 1880 * First, we need to do a direct OF-based probe pass. We
-11
drivers/tty/serial/pmac_zilog.h
··· 43 43 #define PMACZILOG_FLAG_TX_ACTIVE 0x00000040 44 44 #define PMACZILOG_FLAG_IS_IRDA 0x00000100 45 45 #define PMACZILOG_FLAG_IS_INTMODEM 0x00000200 46 - #define PMACZILOG_FLAG_HAS_DMA 0x00000400 47 46 #define PMACZILOG_FLAG_RSRC_REQUESTED 0x00000800 48 47 #define PMACZILOG_FLAG_IS_OPEN 0x00002000 49 48 #define PMACZILOG_FLAG_IS_EXTCLK 0x00008000 ··· 54 55 volatile u8 __iomem *control_reg; 55 56 volatile u8 __iomem *data_reg; 56 57 57 - #ifdef CONFIG_PPC_PMAC 58 - unsigned int tx_dma_irq; 59 - unsigned int rx_dma_irq; 60 - volatile struct dbdma_regs __iomem *tx_dma_regs; 61 - volatile struct dbdma_regs __iomem *rx_dma_regs; 62 - #endif 63 - 64 58 unsigned char irq_name[8]; 65 - 66 - struct ktermios termios_cache; 67 59 }; 68 60 69 61 #define to_pmz(p) ((struct uart_pmac_port *)(p)) ··· 367 377 #define ZS_WANTS_MODEM_STATUS(UP) ((UP)->flags & PMACZILOG_FLAG_MODEM_STATUS) 368 378 #define ZS_IS_IRDA(UP) ((UP)->flags & PMACZILOG_FLAG_IS_IRDA) 369 379 #define ZS_IS_INTMODEM(UP) ((UP)->flags & PMACZILOG_FLAG_IS_INTMODEM) 370 - #define ZS_HAS_DMA(UP) ((UP)->flags & PMACZILOG_FLAG_HAS_DMA) 371 380 #define ZS_IS_OPEN(UP) ((UP)->flags & PMACZILOG_FLAG_IS_OPEN) 372 381 #define ZS_IS_EXTCLK(UP) ((UP)->flags & PMACZILOG_FLAG_IS_EXTCLK) 373 382
+37 -21
drivers/tty/serial/qcom_geni_serial.c
··· 149 149 static void qcom_geni_serial_stop_rx(struct uart_port *uport); 150 150 static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop); 151 151 152 - static const unsigned long root_freq[] = {7372800, 14745600, 19200000, 29491200, 153 - 32000000, 48000000, 51200000, 64000000, 154 - 80000000, 96000000, 100000000, 155 - 102400000, 112000000, 120000000, 156 - 128000000}; 157 - 158 152 #define to_dev_port(ptr, member) \ 159 153 container_of(ptr, struct qcom_geni_serial_port, member) 160 154 ··· 501 507 */ 502 508 qcom_geni_serial_poll_tx_done(uport); 503 509 504 - if (uart_circ_chars_pending(&uport->state->xmit)) { 510 + if (!uart_circ_empty(&uport->state->xmit)) { 505 511 irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 506 512 writel(irq_en | M_TX_FIFO_WATERMARK_EN, 507 513 uport->membase + SE_GENI_M_IRQ_EN); ··· 940 946 return 0; 941 947 } 942 948 943 - static unsigned long get_clk_cfg(unsigned long clk_freq) 944 - { 945 - int i; 946 - 947 - for (i = 0; i < ARRAY_SIZE(root_freq); i++) { 948 - if (!(root_freq[i] % clk_freq)) 949 - return root_freq[i]; 950 - } 951 - return 0; 952 - } 953 - 954 - static unsigned long get_clk_div_rate(unsigned int baud, 949 + static unsigned long get_clk_div_rate(struct clk *clk, unsigned int baud, 955 950 unsigned int sampling_rate, unsigned int *clk_div) 956 951 { 957 952 unsigned long ser_clk; 958 953 unsigned long desired_clk; 954 + unsigned long freq, prev; 955 + unsigned long div, maxdiv; 956 + int64_t mult; 959 957 960 958 desired_clk = baud * sampling_rate; 961 - ser_clk = get_clk_cfg(desired_clk); 959 + if (!desired_clk) { 960 + pr_err("%s: Invalid frequency\n", __func__); 961 + return 0; 962 + } 963 + 964 + maxdiv = CLK_DIV_MSK >> CLK_DIV_SHFT; 965 + prev = 0; 966 + 967 + for (div = 1; div <= maxdiv; div++) { 968 + mult = div * desired_clk; 969 + if (mult > ULONG_MAX) 970 + break; 971 + 972 + freq = clk_round_rate(clk, (unsigned long)mult); 973 + if (!(freq % desired_clk)) { 974 + ser_clk = freq; 975 + break; 976 + } 977 + 978 + if (!prev) 979 + ser_clk = freq; 980 + else if (prev == freq) 981 + break; 982 + 983 + prev = freq; 984 + } 985 + 962 986 if (!ser_clk) { 963 987 pr_err("%s: Can't find matching DFS entry for baud %d\n", 964 988 __func__, baud); ··· 984 972 } 985 973 986 974 *clk_div = ser_clk / desired_clk; 975 + if (!(*clk_div)) 976 + *clk_div = 1; 977 + 987 978 return ser_clk; 988 979 } 989 980 ··· 1018 1003 if (ver >= QUP_SE_VERSION_2_5) 1019 1004 sampling_rate /= 2; 1020 1005 1021 - clk_rate = get_clk_div_rate(baud, sampling_rate, &clk_div); 1006 + clk_rate = get_clk_div_rate(port->se.clk, baud, 1007 + sampling_rate, &clk_div); 1022 1008 if (!clk_rate) 1023 1009 goto out_restart_rx; 1024 1010
+2
drivers/tty/serial/rda-uart.c
··· 262 262 fallthrough; 263 263 case CS7: 264 264 ctrl &= ~RDA_UART_DBITS_8; 265 + termios->c_cflag &= ~CSIZE; 266 + termios->c_cflag |= CS7; 265 267 break; 266 268 default: 267 269 ctrl |= RDA_UART_DBITS_8;
+2 -2
drivers/tty/serial/sa1100.c
··· 446 446 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 447 447 quot = uart_get_divisor(port, baud); 448 448 449 + del_timer_sync(&sport->timer); 450 + 449 451 spin_lock_irqsave(&sport->port.lock, flags); 450 452 451 453 sport->port.read_status_mask &= UTSR0_TO_SM(UTSR0_TFS); ··· 477 475 sport->port.ignore_status_mask |= 478 476 UTSR1_TO_SM(UTSR1_ROR); 479 477 } 480 - 481 - del_timer_sync(&sport->timer); 482 478 483 479 /* 484 480 * Update the per-port timeout.
+13
drivers/tty/serial/samsung_tty.c
··· 2480 2480 unsigned int count) 2481 2481 { 2482 2482 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); 2483 + unsigned long flags; 2484 + bool locked = true; 2483 2485 2484 2486 /* not possible to xmit on unconfigured port */ 2485 2487 if (!s3c24xx_port_configured(ucon)) 2486 2488 return; 2487 2489 2490 + if (cons_uart->sysrq) 2491 + locked = false; 2492 + else if (oops_in_progress) 2493 + locked = spin_trylock_irqsave(&cons_uart->lock, flags); 2494 + else 2495 + spin_lock_irqsave(&cons_uart->lock, flags); 2496 + 2488 2497 uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar); 2498 + 2499 + if (locked) 2500 + spin_unlock_irqrestore(&cons_uart->lock, flags); 2489 2501 } 2490 2502 2491 2503 /* Shouldn't be __init, as it can be instantiated from other module */ ··· 2826 2814 .num_clks = 1, 2827 2815 .clksel_mask = 0, 2828 2816 .clksel_shift = 0, 2817 + .ucon_mask = APPLE_S5L_UCON_MASK, 2829 2818 }, 2830 2819 .def_cfg = { 2831 2820 .ucon = APPLE_S5L_UCON_DEFAULT,
-10
drivers/tty/serial/sc16is7xx.c
··· 1134 1134 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 1135 1135 1136 1136 if (rs485->flags & SER_RS485_ENABLED) { 1137 - bool rts_during_rx, rts_during_tx; 1138 - 1139 - rts_during_rx = rs485->flags & SER_RS485_RTS_AFTER_SEND; 1140 - rts_during_tx = rs485->flags & SER_RS485_RTS_ON_SEND; 1141 - 1142 - if (rts_during_rx == rts_during_tx) 1143 - dev_err(port->dev, 1144 - "unsupported RTS signalling on_send:%d after_send:%d - exactly one of RS485 RTS flags should be set\n", 1145 - rts_during_tx, rts_during_rx); 1146 - 1147 1137 /* 1148 1138 * RTS signal is handled by HW, it's timing can't be influenced. 1149 1139 * However, it's sometimes useful to delay TX even without RTS
+69 -20
drivers/tty/serial/serial_core.c
··· 24 24 #include <linux/sysrq.h> 25 25 #include <linux/delay.h> 26 26 #include <linux/mutex.h> 27 + #include <linux/math64.h> 27 28 #include <linux/security.h> 28 29 29 30 #include <linux/irq.h> ··· 42 41 static struct lock_class_key port_lock_key; 43 42 44 43 #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) 44 + 45 + /* 46 + * Max time with active RTS before/after data is sent. 47 + */ 48 + #define RS485_MAX_RTS_DELAY 100 /* msecs */ 45 49 46 50 static void uart_change_speed(struct tty_struct *tty, struct uart_state *state, 47 51 struct ktermios *old_termios); ··· 339 333 uart_update_timeout(struct uart_port *port, unsigned int cflag, 340 334 unsigned int baud) 341 335 { 342 - unsigned int size; 336 + unsigned int size = tty_get_frame_size(cflag); 337 + u64 frame_time; 343 338 344 - size = tty_get_frame_size(cflag) * port->fifosize; 339 + frame_time = (u64)size * NSEC_PER_SEC; 340 + size *= port->fifosize; 345 341 346 342 /* 347 343 * Figure the timeout to send the above number of bits. 348 344 * Add .02 seconds of slop 349 345 */ 350 346 port->timeout = (HZ * size) / baud + HZ/50; 347 + port->frame_time = DIV64_U64_ROUND_UP(frame_time, baud); 351 348 } 352 349 EXPORT_SYMBOL(uart_update_timeout); 353 350 ··· 1305 1296 if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) 1306 1297 return -EFAULT; 1307 1298 1299 + /* pick sane settings if the user hasn't */ 1300 + if (!(rs485.flags & SER_RS485_RTS_ON_SEND) == 1301 + !(rs485.flags & SER_RS485_RTS_AFTER_SEND)) { 1302 + dev_warn_ratelimited(port->dev, 1303 + "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", 1304 + port->name, port->line); 1305 + rs485.flags |= SER_RS485_RTS_ON_SEND; 1306 + rs485.flags &= ~SER_RS485_RTS_AFTER_SEND; 1307 + } 1308 + 1309 + if (rs485.delay_rts_before_send > RS485_MAX_RTS_DELAY) { 1310 + rs485.delay_rts_before_send = RS485_MAX_RTS_DELAY; 1311 + dev_warn_ratelimited(port->dev, 1312 + "%s (%d): RTS delay before sending clamped to %u ms\n", 1313 + port->name, port->line, rs485.delay_rts_before_send); 1314 + } 1315 + 1316 + if (rs485.delay_rts_after_send > RS485_MAX_RTS_DELAY) { 1317 + rs485.delay_rts_after_send = RS485_MAX_RTS_DELAY; 1318 + dev_warn_ratelimited(port->dev, 1319 + "%s (%d): RTS delay after sending clamped to %u ms\n", 1320 + port->name, port->line, rs485.delay_rts_after_send); 1321 + } 1322 + /* Return clean padding area to userspace */ 1323 + memset(rs485.padding, 0, sizeof(rs485.padding)); 1324 + 1308 1325 spin_lock_irqsave(&port->lock, flags); 1309 1326 ret = port->rs485_config(port, &rs485); 1327 + if (!ret) 1328 + port->rs485 = rs485; 1310 1329 spin_unlock_irqrestore(&port->lock, flags); 1311 1330 if (ret) 1312 1331 return ret; ··· 1647 1610 * Note: we have to use pretty tight timings here to satisfy 1648 1611 * the NIST-PCTS. 1649 1612 */ 1650 - char_time = (port->timeout - HZ/50) / port->fifosize; 1651 - char_time = char_time / 5; 1652 - if (char_time == 0) 1653 - char_time = 1; 1613 + char_time = max(nsecs_to_jiffies(port->frame_time / 5), 1UL); 1614 + 1654 1615 if (timeout && timeout < char_time) 1655 1616 char_time = timeout; 1656 1617 1657 - /* 1658 - * If the transmitter hasn't cleared in twice the approximate 1659 - * amount of time to send the entire FIFO, it probably won't 1660 - * ever clear. This assumes the UART isn't doing flow 1661 - * control, which is currently the case. Hence, if it ever 1662 - * takes longer than port->timeout, this is probably due to a 1663 - * UART bug of some kind. So, we clamp the timeout parameter at 1664 - * 2*port->timeout. 1665 - */ 1666 - if (timeout == 0 || timeout > 2 * port->timeout) 1667 - timeout = 2 * port->timeout; 1618 + if (!uart_cts_enabled(port)) { 1619 + /* 1620 + * If the transmitter hasn't cleared in twice the approximate 1621 + * amount of time to send the entire FIFO, it probably won't 1622 + * ever clear. This assumes the UART isn't doing flow 1623 + * control, which is currently the case. Hence, if it ever 1624 + * takes longer than port->timeout, this is probably due to a 1625 + * UART bug of some kind. So, we clamp the timeout parameter at 1626 + * 2*port->timeout. 1627 + */ 1628 + if (timeout == 0 || timeout > 2 * port->timeout) 1629 + timeout = 2 * port->timeout; 1630 + } 1668 1631 1669 1632 expire = jiffies + timeout; 1670 1633 ··· 1680 1643 msleep_interruptible(jiffies_to_msecs(char_time)); 1681 1644 if (signal_pending(current)) 1682 1645 break; 1683 - if (time_after(jiffies, expire)) 1646 + if (timeout && time_after(jiffies, expire)) 1684 1647 break; 1685 1648 } 1686 1649 uart_port_deref(port); ··· 2211 2174 } 2212 2175 put_device(tty_dev); 2213 2176 2214 - /* Nothing to do if the console is not suspending */ 2215 - if (!console_suspend_enabled && uart_console(uport)) 2177 + /* 2178 + * Nothing to do if the console is not suspending 2179 + * except stop_rx to prevent any asynchronous data 2180 + * over RX line. Re-start_rx, when required, is 2181 + * done by set_termios in resume sequence 2182 + */ 2183 + if (!console_suspend_enabled && uart_console(uport)) { 2184 + uport->ops->stop_rx(uport); 2216 2185 goto unlock; 2186 + } 2217 2187 2218 2188 uport->suspended = 1; 2219 2189 2220 2190 if (tty_port_initialized(port)) { 2221 2191 const struct uart_ops *ops = uport->ops; 2222 2192 int tries; 2193 + unsigned int mctrl; 2223 2194 2224 2195 tty_port_set_suspended(port, 1); 2225 2196 tty_port_set_initialized(port, 0); ··· 2235 2190 spin_lock_irq(&uport->lock); 2236 2191 ops->stop_tx(uport); 2237 2192 ops->set_mctrl(uport, 0); 2193 + /* save mctrl so it can be restored on resume */ 2194 + mctrl = uport->mctrl; 2195 + uport->mctrl = 0; 2238 2196 ops->stop_rx(uport); 2239 2197 spin_unlock_irq(&uport->lock); 2240 2198 ··· 2251 2203 uport->name); 2252 2204 2253 2205 ops->shutdown(uport); 2206 + uport->mctrl = mctrl; 2254 2207 } 2255 2208 2256 2209 /*
+2
drivers/tty/serial/serial_txx9.c
··· 618 618 case CS6: /* not supported */ 619 619 case CS8: 620 620 cval |= TXX9_SILCR_UMODE_8BIT; 621 + termios->c_cflag &= ~CSIZE; 622 + termios->c_cflag |= CS8; 621 623 break; 622 624 } 623 625
+5 -1
drivers/tty/serial/sh-sci.c
··· 2379 2379 int best_clk = -1; 2380 2380 unsigned long flags; 2381 2381 2382 - if ((termios->c_cflag & CSIZE) == CS7) 2382 + if ((termios->c_cflag & CSIZE) == CS7) { 2383 2383 smr_val |= SCSMR_CHR; 2384 + } else { 2385 + termios->c_cflag &= ~CSIZE; 2386 + termios->c_cflag |= CS8; 2387 + } 2384 2388 if (termios->c_cflag & PARENB) 2385 2389 smr_val |= SCSMR_PE; 2386 2390 if (termios->c_cflag & PARODD)
+11 -9
drivers/tty/serial/sifive.c
··· 148 148 * @port: struct uart_port embedded in this struct 149 149 * @dev: struct device * 150 150 * @ier: shadowed copy of the interrupt enable register 151 - * @clkin_rate: input clock to the UART IP block. 152 151 * @baud_rate: UART serial line rate (e.g., 115200 baud) 153 152 * @clk: reference to this device's clock 154 153 * @clk_notifier: clock rate change notifier for upstream clock changes ··· 158 159 struct uart_port port; 159 160 struct device *dev; 160 161 unsigned char ier; 161 - unsigned long clkin_rate; 162 162 unsigned long baud_rate; 163 163 struct clk *clk; 164 164 struct notifier_block clk_notifier; ··· 461 463 { 462 464 u16 div; 463 465 464 - div = DIV_ROUND_UP(ssp->clkin_rate, ssp->baud_rate) - 1; 466 + div = DIV_ROUND_UP(ssp->port.uartclk, ssp->baud_rate) - 1; 465 467 466 468 __ssp_writel(div, SIFIVE_SERIAL_DIV_OFFS, ssp); 467 469 } ··· 646 648 udelay(DIV_ROUND_UP(12 * 1000 * 1000, ssp->baud_rate)); 647 649 } 648 650 649 - if (event == POST_RATE_CHANGE && ssp->clkin_rate != cnd->new_rate) { 650 - ssp->clkin_rate = cnd->new_rate; 651 + if (event == POST_RATE_CHANGE && ssp->port.uartclk != cnd->new_rate) { 652 + ssp->port.uartclk = cnd->new_rate; 651 653 __ssp_update_div(ssp); 652 654 } 653 655 ··· 664 666 int rate; 665 667 char nstop; 666 668 667 - if ((termios->c_cflag & CSIZE) != CS8) 669 + if ((termios->c_cflag & CSIZE) != CS8) { 668 670 dev_err_once(ssp->port.dev, "only 8-bit words supported\n"); 671 + termios->c_cflag &= ~CSIZE; 672 + termios->c_cflag |= CS8; 673 + } 669 674 if (termios->c_iflag & (INPCK | PARMRK)) 670 675 dev_err_once(ssp->port.dev, "parity checking not supported\n"); 671 676 if (termios->c_iflag & BRKINT) 672 677 dev_err_once(ssp->port.dev, "BREAK detection not supported\n"); 678 + termios->c_iflag &= ~(INPCK|PARMRK|BRKINT); 673 679 674 680 /* Set number of stop bits */ 675 681 nstop = (termios->c_cflag & CSTOPB) ? 2 : 1; 676 682 __ssp_set_stop_bits(ssp, nstop); 677 683 678 684 /* Set line rate */ 679 - rate = uart_get_baud_rate(port, termios, old, 0, ssp->clkin_rate / 16); 685 + rate = uart_get_baud_rate(port, termios, old, 0, 686 + ssp->port.uartclk / 16); 680 687 __ssp_update_baud_rate(ssp, rate); 681 688 682 689 spin_lock_irqsave(&ssp->port.lock, flags); ··· 999 996 } 1000 997 1001 998 /* Set up clock divider */ 1002 - ssp->clkin_rate = clk_get_rate(ssp->clk); 999 + ssp->port.uartclk = clk_get_rate(ssp->clk); 1003 1000 ssp->baud_rate = SIFIVE_DEFAULT_BAUD_RATE; 1004 - ssp->port.uartclk = ssp->baud_rate * 16; 1005 1001 __ssp_update_div(ssp); 1006 1002 1007 1003 platform_set_drvdata(pdev, ssp);
+4
drivers/tty/serial/st-asc.c
··· 535 535 /* set character length */ 536 536 if ((cflag & CSIZE) == CS7) { 537 537 ctrl_val |= ASC_CTL_MODE_7BIT_PAR; 538 + cflag |= PARENB; 538 539 } else { 539 540 ctrl_val |= (cflag & PARENB) ? ASC_CTL_MODE_8BIT_PAR : 540 541 ASC_CTL_MODE_8BIT; 542 + cflag &= ~CSIZE; 543 + cflag |= CS8; 541 544 } 545 + termios->c_cflag = cflag; 542 546 543 547 /* set stop bit */ 544 548 ctrl_val |= (cflag & CSTOPB) ? ASC_CTL_STOP_2BIT : ASC_CTL_STOP_1BIT;
+187 -38
drivers/tty/serial/stm32-usart.c
··· 37 37 38 38 static void stm32_usart_stop_tx(struct uart_port *port); 39 39 static void stm32_usart_transmit_chars(struct uart_port *port); 40 + static void __maybe_unused stm32_usart_console_putchar(struct uart_port *port, unsigned char ch); 40 41 41 42 static inline struct stm32_port *to_stm32_port(struct uart_port *port) 42 43 { ··· 108 107 109 108 stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); 110 109 111 - port->rs485 = *rs485conf; 112 - 113 110 rs485conf->flags |= SER_RS485_RX_DURING_TX; 114 111 115 112 if (rs485conf->flags & SER_RS485_ENABLED) { ··· 127 128 rs485conf->delay_rts_after_send, 128 129 baud); 129 130 130 - if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 131 + if (rs485conf->flags & SER_RS485_RTS_ON_SEND) 131 132 cr3 &= ~USART_CR3_DEP; 132 - rs485conf->flags &= ~SER_RS485_RTS_AFTER_SEND; 133 - } else { 133 + else 134 134 cr3 |= USART_CR3_DEP; 135 - rs485conf->flags |= SER_RS485_RTS_AFTER_SEND; 136 - } 137 135 138 136 writel_relaxed(cr3, port->membase + ofs->cr3); 139 137 writel_relaxed(cr1, port->membase + ofs->cr1); ··· 417 421 stm32_usart_set_bits(port, ofs->cr1, USART_CR1_TXEIE); 418 422 } 419 423 424 + static void stm32_usart_tc_interrupt_enable(struct uart_port *port) 425 + { 426 + struct stm32_port *stm32_port = to_stm32_port(port); 427 + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 428 + 429 + stm32_usart_set_bits(port, ofs->cr1, USART_CR1_TCIE); 430 + } 431 + 420 432 static void stm32_usart_rx_dma_complete(void *arg) 421 433 { 422 434 struct uart_port *port = arg; ··· 448 444 stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_TXFTIE); 449 445 else 450 446 stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_TXEIE); 447 + } 448 + 449 + static void stm32_usart_tc_interrupt_disable(struct uart_port *port) 450 + { 451 + struct stm32_port *stm32_port = to_stm32_port(port); 452 + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 453 + 454 + stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_TCIE); 455 + } 456 + 457 + static void stm32_usart_rs485_rts_enable(struct uart_port *port) 458 + { 459 + struct stm32_port *stm32_port = to_stm32_port(port); 460 + struct serial_rs485 *rs485conf = &port->rs485; 461 + 462 + if (stm32_port->hw_flow_control || 463 + !(rs485conf->flags & SER_RS485_ENABLED)) 464 + return; 465 + 466 + if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 467 + mctrl_gpio_set(stm32_port->gpios, 468 + stm32_port->port.mctrl | TIOCM_RTS); 469 + } else { 470 + mctrl_gpio_set(stm32_port->gpios, 471 + stm32_port->port.mctrl & ~TIOCM_RTS); 472 + } 473 + } 474 + 475 + static void stm32_usart_rs485_rts_disable(struct uart_port *port) 476 + { 477 + struct stm32_port *stm32_port = to_stm32_port(port); 478 + struct serial_rs485 *rs485conf = &port->rs485; 479 + 480 + if (stm32_port->hw_flow_control || 481 + !(rs485conf->flags & SER_RS485_ENABLED)) 482 + return; 483 + 484 + if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 485 + mctrl_gpio_set(stm32_port->gpios, 486 + stm32_port->port.mctrl & ~TIOCM_RTS); 487 + } else { 488 + mctrl_gpio_set(stm32_port->gpios, 489 + stm32_port->port.mctrl | TIOCM_RTS); 490 + } 451 491 } 452 492 453 493 static void stm32_usart_transmit_chars_pio(struct uart_port *port) ··· 601 553 u32 isr; 602 554 int ret; 603 555 556 + if (!stm32_port->hw_flow_control && 557 + port->rs485.flags & SER_RS485_ENABLED) { 558 + stm32_port->txdone = false; 559 + stm32_usart_tc_interrupt_disable(port); 560 + stm32_usart_rs485_rts_enable(port); 561 + } 562 + 604 563 if (port->x_char) { 605 564 if (stm32_usart_tx_dma_started(stm32_port) && 606 565 stm32_usart_tx_dma_enabled(stm32_port)) ··· 648 593 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 649 594 uart_write_wakeup(port); 650 595 651 - if (uart_circ_empty(xmit)) 596 + if (uart_circ_empty(xmit)) { 652 597 stm32_usart_tx_interrupt_disable(port); 598 + if (!stm32_port->hw_flow_control && 599 + port->rs485.flags & SER_RS485_ENABLED) { 600 + stm32_port->txdone = true; 601 + stm32_usart_tc_interrupt_enable(port); 602 + } 603 + } 653 604 } 654 605 655 606 static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ··· 668 607 unsigned int size; 669 608 670 609 sr = readl_relaxed(port->membase + ofs->isr); 610 + 611 + if (!stm32_port->hw_flow_control && 612 + port->rs485.flags & SER_RS485_ENABLED && 613 + (sr & USART_SR_TC)) { 614 + stm32_usart_tc_interrupt_disable(port); 615 + stm32_usart_rs485_rts_disable(port); 616 + } 671 617 672 618 if ((sr & USART_SR_RTOF) && ofs->icr != UNDEF_REG) 673 619 writel_relaxed(USART_ICR_RTOCF, ··· 785 717 static void stm32_usart_stop_tx(struct uart_port *port) 786 718 { 787 719 struct stm32_port *stm32_port = to_stm32_port(port); 788 - struct serial_rs485 *rs485conf = &port->rs485; 789 720 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 790 721 791 722 stm32_usart_tx_interrupt_disable(port); 792 723 if (stm32_usart_tx_dma_started(stm32_port) && stm32_usart_tx_dma_enabled(stm32_port)) 793 724 stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 794 725 795 - if (rs485conf->flags & SER_RS485_ENABLED) { 796 - if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 797 - mctrl_gpio_set(stm32_port->gpios, 798 - stm32_port->port.mctrl & ~TIOCM_RTS); 799 - } else { 800 - mctrl_gpio_set(stm32_port->gpios, 801 - stm32_port->port.mctrl | TIOCM_RTS); 802 - } 803 - } 726 + stm32_usart_rs485_rts_disable(port); 804 727 } 805 728 806 729 /* There are probably characters waiting to be transmitted. */ 807 730 static void stm32_usart_start_tx(struct uart_port *port) 808 731 { 809 - struct stm32_port *stm32_port = to_stm32_port(port); 810 - struct serial_rs485 *rs485conf = &port->rs485; 811 732 struct circ_buf *xmit = &port->state->xmit; 812 733 813 - if (uart_circ_empty(xmit) && !port->x_char) 734 + if (uart_circ_empty(xmit) && !port->x_char) { 735 + stm32_usart_rs485_rts_disable(port); 814 736 return; 815 - 816 - if (rs485conf->flags & SER_RS485_ENABLED) { 817 - if (rs485conf->flags & SER_RS485_RTS_ON_SEND) { 818 - mctrl_gpio_set(stm32_port->gpios, 819 - stm32_port->port.mctrl | TIOCM_RTS); 820 - } else { 821 - mctrl_gpio_set(stm32_port->gpios, 822 - stm32_port->port.mctrl & ~TIOCM_RTS); 823 - } 824 737 } 738 + 739 + stm32_usart_rs485_rts_enable(port); 825 740 826 741 stm32_usart_transmit_chars(port); 827 742 } ··· 1088 1037 * CS8 or (CS7 + parity), 8 bits word aka [M1:M0] = 0b00 1089 1038 * M0 and M1 already cleared by cr1 initialization. 1090 1039 */ 1091 - if (bits == 9) 1040 + if (bits == 9) { 1092 1041 cr1 |= USART_CR1_M0; 1093 - else if ((bits == 7) && cfg->has_7bits_data) 1042 + } else if ((bits == 7) && cfg->has_7bits_data) { 1094 1043 cr1 |= USART_CR1_M1; 1095 - else if (bits != 8) 1044 + } else if (bits != 8) { 1096 1045 dev_dbg(port->dev, "Unsupported data bits config: %u bits\n" 1097 1046 , bits); 1047 + cflag &= ~CSIZE; 1048 + cflag |= CS8; 1049 + termios->c_cflag = cflag; 1050 + bits = 8; 1051 + if (cflag & PARENB) { 1052 + bits++; 1053 + cr1 |= USART_CR1_M0; 1054 + } 1055 + } 1098 1056 1099 1057 if (ofs->rtor != UNDEF_REG && (stm32_port->rx_ch || 1100 1058 (stm32_port->fifoen && ··· 1282 1222 } 1283 1223 } 1284 1224 1225 + #if defined(CONFIG_CONSOLE_POLL) 1226 + 1227 + /* Callbacks for characters polling in debug context (i.e. KGDB). */ 1228 + static int stm32_usart_poll_init(struct uart_port *port) 1229 + { 1230 + struct stm32_port *stm32_port = to_stm32_port(port); 1231 + 1232 + return clk_prepare_enable(stm32_port->clk); 1233 + } 1234 + 1235 + static int stm32_usart_poll_get_char(struct uart_port *port) 1236 + { 1237 + struct stm32_port *stm32_port = to_stm32_port(port); 1238 + const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 1239 + 1240 + if (!(readl_relaxed(port->membase + ofs->isr) & USART_SR_RXNE)) 1241 + return NO_POLL_CHAR; 1242 + 1243 + return readl_relaxed(port->membase + ofs->rdr) & stm32_port->rdr_mask; 1244 + } 1245 + 1246 + static void stm32_usart_poll_put_char(struct uart_port *port, unsigned char ch) 1247 + { 1248 + stm32_usart_console_putchar(port, ch); 1249 + } 1250 + #endif /* CONFIG_CONSOLE_POLL */ 1251 + 1285 1252 static const struct uart_ops stm32_uart_ops = { 1286 1253 .tx_empty = stm32_usart_tx_empty, 1287 1254 .set_mctrl = stm32_usart_set_mctrl, ··· 1330 1243 .request_port = stm32_usart_request_port, 1331 1244 .config_port = stm32_usart_config_port, 1332 1245 .verify_port = stm32_usart_verify_port, 1246 + #if defined(CONFIG_CONSOLE_POLL) 1247 + .poll_init = stm32_usart_poll_init, 1248 + .poll_get_char = stm32_usart_poll_get_char, 1249 + .poll_put_char = stm32_usart_poll_put_char, 1250 + #endif /* CONFIG_CONSOLE_POLL */ 1333 1251 }; 1334 1252 1335 1253 /* ··· 1732 1640 return 0; 1733 1641 } 1734 1642 1735 - #ifdef CONFIG_SERIAL_STM32_CONSOLE 1736 - static void stm32_usart_console_putchar(struct uart_port *port, unsigned char ch) 1643 + static void __maybe_unused stm32_usart_console_putchar(struct uart_port *port, unsigned char ch) 1737 1644 { 1738 1645 struct stm32_port *stm32_port = to_stm32_port(port); 1739 1646 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 1647 + u32 isr; 1648 + int ret; 1740 1649 1741 - while (!(readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE)) 1742 - cpu_relax(); 1743 - 1650 + ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, isr, 1651 + (isr & USART_SR_TXE), 100, 1652 + STM32_USART_TIMEOUT_USEC); 1653 + if (ret != 0) { 1654 + dev_err(port->dev, "Error while sending data in UART TX : %d\n", ret); 1655 + return; 1656 + } 1744 1657 writel_relaxed(ch, port->membase + ofs->tdr); 1745 1658 } 1746 1659 1660 + #ifdef CONFIG_SERIAL_STM32_CONSOLE 1747 1661 static void stm32_usart_console_write(struct console *co, const char *s, 1748 1662 unsigned int cnt) 1749 1663 { ··· 1824 1726 #else 1825 1727 #define STM32_SERIAL_CONSOLE NULL 1826 1728 #endif /* CONFIG_SERIAL_STM32_CONSOLE */ 1729 + 1730 + #ifdef CONFIG_SERIAL_EARLYCON 1731 + static void early_stm32_usart_console_putchar(struct uart_port *port, unsigned char ch) 1732 + { 1733 + struct stm32_usart_info *info = port->private_data; 1734 + 1735 + while (!(readl_relaxed(port->membase + info->ofs.isr) & USART_SR_TXE)) 1736 + cpu_relax(); 1737 + 1738 + writel_relaxed(ch, port->membase + info->ofs.tdr); 1739 + } 1740 + 1741 + static void early_stm32_serial_write(struct console *console, const char *s, unsigned int count) 1742 + { 1743 + struct earlycon_device *device = console->data; 1744 + struct uart_port *port = &device->port; 1745 + 1746 + uart_console_write(port, s, count, early_stm32_usart_console_putchar); 1747 + } 1748 + 1749 + static int __init early_stm32_h7_serial_setup(struct earlycon_device *device, const char *options) 1750 + { 1751 + if (!(device->port.membase || device->port.iobase)) 1752 + return -ENODEV; 1753 + device->port.private_data = &stm32h7_info; 1754 + device->con->write = early_stm32_serial_write; 1755 + return 0; 1756 + } 1757 + 1758 + static int __init early_stm32_f7_serial_setup(struct earlycon_device *device, const char *options) 1759 + { 1760 + if (!(device->port.membase || device->port.iobase)) 1761 + return -ENODEV; 1762 + device->port.private_data = &stm32f7_info; 1763 + device->con->write = early_stm32_serial_write; 1764 + return 0; 1765 + } 1766 + 1767 + static int __init early_stm32_f4_serial_setup(struct earlycon_device *device, const char *options) 1768 + { 1769 + if (!(device->port.membase || device->port.iobase)) 1770 + return -ENODEV; 1771 + device->port.private_data = &stm32f4_info; 1772 + device->con->write = early_stm32_serial_write; 1773 + return 0; 1774 + } 1775 + 1776 + OF_EARLYCON_DECLARE(stm32, "st,stm32h7-uart", early_stm32_h7_serial_setup); 1777 + OF_EARLYCON_DECLARE(stm32, "st,stm32f7-uart", early_stm32_f7_serial_setup); 1778 + OF_EARLYCON_DECLARE(stm32, "st,stm32-uart", early_stm32_f4_serial_setup); 1779 + #endif /* CONFIG_SERIAL_EARLYCON */ 1827 1780 1828 1781 static struct uart_driver stm32_usart_driver = { 1829 1782 .driver_name = DRIVER_NAME,
+3
drivers/tty/serial/stm32-usart.h
··· 251 251 #define RX_BUF_P (RX_BUF_L / 2) /* dma rx buffer period */ 252 252 #define TX_BUF_L RX_BUF_L /* dma tx buffer length */ 253 253 254 + #define STM32_USART_TIMEOUT_USEC USEC_PER_SEC /* 1s timeout in µs */ 255 + 254 256 struct stm32_port { 255 257 struct uart_port port; 256 258 struct clk *clk; ··· 271 269 bool hw_flow_control; 272 270 bool swap; /* swap RX & TX pins */ 273 271 bool fifoen; 272 + bool txdone; 274 273 int rxftcfg; /* RX FIFO threshold CFG */ 275 274 int txftcfg; /* TX FIFO threshold CFG */ 276 275 bool wakeup_src;
+1 -1
drivers/tty/serial/sunplus-uart.c
··· 498 498 }; 499 499 500 500 #ifdef CONFIG_SERIAL_SUNPLUS_CONSOLE 501 - struct sunplus_uart_port *sunplus_console_ports[SUP_UART_NR]; 501 + static struct sunplus_uart_port *sunplus_console_ports[SUP_UART_NR]; 502 502 503 503 static void sunplus_uart_console_putchar(struct uart_port *port, 504 504 unsigned char ch)
-2
drivers/tty/serial/sunsu.c
··· 798 798 cval |= UART_LCR_PARITY; 799 799 if (!(cflag & PARODD)) 800 800 cval |= UART_LCR_EPAR; 801 - #ifdef CMSPAR 802 801 if (cflag & CMSPAR) 803 802 cval |= UART_LCR_SPAR; 804 - #endif 805 803 806 804 /* 807 805 * Work around a bug in the Oxford Semiconductor 952 rev B
+2 -1
drivers/tty/serial/uartlite.c
··· 321 321 struct uartlite_data *pdata = port->private_data; 322 322 323 323 /* Set termios to what the hardware supports */ 324 - termios->c_cflag &= ~(BRKINT | CSTOPB | PARENB | PARODD | CSIZE); 324 + termios->c_iflag &= ~BRKINT; 325 + termios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CSIZE); 325 326 termios->c_cflag |= pdata->cflags & (PARENB | PARODD | CSIZE); 326 327 tty_termios_encode_baud_rate(termios, pdata->baud, pdata->baud); 327 328
+17 -31
drivers/tty/serial/xilinx_uartps.c
··· 313 313 static void cdns_uart_handle_tx(void *dev_id) 314 314 { 315 315 struct uart_port *port = (struct uart_port *)dev_id; 316 + struct circ_buf *xmit = &port->state->xmit; 316 317 unsigned int numbytes; 317 318 318 - if (uart_circ_empty(&port->state->xmit)) { 319 + if (uart_circ_empty(xmit)) { 319 320 writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IDR); 320 - } else { 321 - numbytes = port->fifosize; 322 - while (numbytes && !uart_circ_empty(&port->state->xmit) && 323 - !(readl(port->membase + CDNS_UART_SR) & 324 - CDNS_UART_SR_TXFULL)) { 325 - /* 326 - * Get the data from the UART circular buffer 327 - * and write it to the cdns_uart's TX_FIFO 328 - * register. 329 - */ 330 - writel( 331 - port->state->xmit.buf[port->state->xmit.tail], 332 - port->membase + CDNS_UART_FIFO); 333 - 334 - port->icount.tx++; 335 - 336 - /* 337 - * Adjust the tail of the UART buffer and wrap 338 - * the buffer if it reaches limit. 339 - */ 340 - port->state->xmit.tail = 341 - (port->state->xmit.tail + 1) & 342 - (UART_XMIT_SIZE - 1); 343 - 344 - numbytes--; 345 - } 346 - 347 - if (uart_circ_chars_pending( 348 - &port->state->xmit) < WAKEUP_CHARS) 349 - uart_write_wakeup(port); 321 + return; 350 322 } 323 + 324 + numbytes = port->fifosize; 325 + while (numbytes && !uart_circ_empty(xmit) && 326 + !(readl(port->membase + CDNS_UART_SR) & CDNS_UART_SR_TXFULL)) { 327 + 328 + writel(xmit->buf[xmit->tail], port->membase + CDNS_UART_FIFO); 329 + 330 + port->icount.tx++; 331 + xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 332 + numbytes--; 333 + } 334 + 335 + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 336 + uart_write_wakeup(port); 351 337 } 352 338 353 339 /**
+1 -1
drivers/tty/serial/zs.c
··· 981 981 static void zs_release_port(struct uart_port *uport) 982 982 { 983 983 iounmap(uport->membase); 984 - uport->membase = 0; 984 + uport->membase = NULL; 985 985 release_mem_region(uport->mapbase, ZS_CHAN_IO_SIZE); 986 986 } 987 987
+15 -12
drivers/tty/sysrq.c
··· 232 232 unsigned long flags; 233 233 234 234 /* Idle CPUs have no interesting backtrace. */ 235 - if (idle_cpu(smp_processor_id())) 235 + if (idle_cpu(smp_processor_id())) { 236 + pr_info("CPU%d: backtrace skipped as idling\n", smp_processor_id()); 236 237 return; 238 + } 237 239 238 240 raw_spin_lock_irqsave(&show_lock, flags); 239 241 pr_info("CPU%d:\n", smp_processor_id()); ··· 262 260 263 261 if (in_hardirq()) 264 262 regs = get_irq_regs(); 265 - if (regs) { 266 - pr_info("CPU%d:\n", smp_processor_id()); 263 + 264 + pr_info("CPU%d:\n", smp_processor_id()); 265 + if (regs) 267 266 show_regs(regs); 268 - } 267 + else 268 + show_stack(NULL, NULL, KERN_INFO); 269 + 269 270 schedule_work(&sysrq_showallcpus); 270 271 } 271 272 } ··· 279 274 .action_msg = "Show backtrace of all active CPUs", 280 275 .enable_mask = SYSRQ_ENABLE_DUMP, 281 276 }; 277 + #else 278 + #define sysrq_showallcpus_op (*(const struct sysrq_key_op *)NULL) 282 279 #endif 283 280 284 281 static void sysrq_handle_showregs(int key) ··· 412 405 .enable_mask = SYSRQ_ENABLE_SIGNAL, 413 406 }; 414 407 408 + #ifdef CONFIG_BLOCK 415 409 static void sysrq_handle_thaw(int key) 416 410 { 417 411 emergency_thaw_all(); ··· 423 415 .action_msg = "Emergency Thaw of all frozen filesystems", 424 416 .enable_mask = SYSRQ_ENABLE_SIGNAL, 425 417 }; 418 + #else 419 + #define sysrq_thaw_op (*(const struct sysrq_key_op *)NULL) 420 + #endif 426 421 427 422 static void sysrq_handle_kill(int key) 428 423 { ··· 479 468 NULL, /* g */ 480 469 NULL, /* h - reserved for help */ 481 470 &sysrq_kill_op, /* i */ 482 - #ifdef CONFIG_BLOCK 483 471 &sysrq_thaw_op, /* j */ 484 - #else 485 - NULL, /* j */ 486 - #endif 487 472 &sysrq_SAK_op, /* k */ 488 - #ifdef CONFIG_SMP 489 473 &sysrq_showallcpus_op, /* l */ 490 - #else 491 - NULL, /* l */ 492 - #endif 493 474 &sysrq_showmem_op, /* m */ 494 475 &sysrq_unrt_op, /* n */ 495 476 /* o: This will often be registered as 'Off' at init time */
+8 -27
drivers/tty/tty_baudrate.c
··· 61 61 62 62 cbaud = termios->c_cflag & CBAUD; 63 63 64 - #ifdef BOTHER 65 64 /* Magic token for arbitrary speed via c_ispeed/c_ospeed */ 66 65 if (cbaud == BOTHER) 67 66 return termios->c_ospeed; 68 - #endif 67 + 69 68 if (cbaud & CBAUDEX) { 70 69 cbaud &= ~CBAUDEX; 71 70 ··· 91 92 92 93 speed_t tty_termios_input_baud_rate(struct ktermios *termios) 93 94 { 94 - #ifdef IBSHIFT 95 95 unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD; 96 96 97 97 if (cbaud == B0) 98 98 return tty_termios_baud_rate(termios); 99 - #ifdef BOTHER 99 + 100 100 /* Magic token for arbitrary speed via c_ispeed*/ 101 101 if (cbaud == BOTHER) 102 102 return termios->c_ispeed; 103 - #endif 103 + 104 104 if (cbaud & CBAUDEX) { 105 105 cbaud &= ~CBAUDEX; 106 106 ··· 109 111 cbaud += 15; 110 112 } 111 113 return cbaud >= n_baud_table ? 0 : baud_table[cbaud]; 112 - #else /* IBSHIFT */ 113 - return tty_termios_baud_rate(termios); 114 - #endif /* IBSHIFT */ 115 114 } 116 115 EXPORT_SYMBOL(tty_termios_input_baud_rate); 117 116 ··· 148 153 termios->c_ispeed = ibaud; 149 154 termios->c_ospeed = obaud; 150 155 151 - #ifdef IBSHIFT 152 156 if (((termios->c_cflag >> IBSHIFT) & CBAUD) != B0) 153 157 ibinput = 1; /* An input speed was specified */ 154 - #endif 155 - #ifdef BOTHER 158 + 156 159 /* If the user asked for a precise weird speed give a precise weird 157 160 * answer. If they asked for a Bfoo speed they may have problems 158 161 * digesting non-exact replies so fuzz a bit. ··· 163 170 } 164 171 if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER) 165 172 iclose = 0; 166 - #endif 173 + 167 174 termios->c_cflag &= ~CBAUD; 168 - #ifdef IBSHIFT 169 175 termios->c_cflag &= ~(CBAUD << IBSHIFT); 170 - #endif 171 176 172 177 /* 173 178 * Our goal is to find a close match to the standard baud rate ··· 185 194 /* For the case input == output don't set IBAUD bits 186 195 * if the user didn't do so. 187 196 */ 188 - if (ofound == i && !ibinput) 197 + if (ofound == i && !ibinput) { 189 198 ifound = i; 190 - #ifdef IBSHIFT 191 - else { 199 + } else { 192 200 ifound = i; 193 201 termios->c_cflag |= (baud_bits[i] << IBSHIFT); 194 202 } 195 - #endif 196 203 } 197 204 } while (++i < n_baud_table); 198 205 199 - /* 200 - * If we found no match then use BOTHER if provided or warn 201 - * the user their platform maintainer needs to wake up if not. 202 - */ 203 - #ifdef BOTHER 206 + /* If we found no match then use BOTHER. */ 204 207 if (ofound == -1) 205 208 termios->c_cflag |= BOTHER; 206 209 /* Set exact input bits only if the input and output differ or the ··· 202 217 */ 203 218 if (ifound == -1 && (ibaud != obaud || ibinput)) 204 219 termios->c_cflag |= (BOTHER << IBSHIFT); 205 - #else 206 - if (ifound == -1 || ofound == -1) 207 - pr_warn_once("tty: Unable to return correct speed data as your architecture needs updating.\n"); 208 - #endif 209 220 } 210 221 EXPORT_SYMBOL_GPL(tty_termios_encode_baud_rate); 211 222
-2
drivers/tty/tty_ioctl.c
··· 562 562 termios.c_cc[VKILL] = tmp.sg_kill; 563 563 set_sgflags(&termios, tmp.sg_flags); 564 564 /* Try and encode into Bfoo format */ 565 - #ifdef BOTHER 566 565 tty_termios_encode_baud_rate(&termios, termios.c_ispeed, 567 566 termios.c_ospeed); 568 - #endif 569 567 up_write(&tty->termios_rwsem); 570 568 tty_set_termios(tty, &termios); 571 569 return 0;
-8
drivers/usb/class/cdc-acm.h
··· 8 8 */ 9 9 10 10 /* 11 - * CMSPAR, some architectures can't have space and mark parity. 12 - */ 13 - 14 - #ifndef CMSPAR 15 - #define CMSPAR 0 16 - #endif 17 - 18 - /* 19 11 * Major and minor numbers. 20 12 */ 21 13
+1 -2
drivers/usb/serial/ark3116.c
··· 208 208 lcr |= UART_LCR_PARITY; 209 209 if (!(cflag & PARODD)) 210 210 lcr |= UART_LCR_EPAR; 211 - #ifdef CMSPAR 212 211 if (cflag & CMSPAR) 213 212 lcr |= UART_LCR_SPAR; 214 - #endif 213 + 215 214 /* handshake control */ 216 215 hcr = (cflag & CRTSCTS) ? 0x03 : 0x00; 217 216
-4
drivers/usb/serial/whiteheat.c
··· 30 30 #include <linux/usb/ezusb.h> 31 31 #include "whiteheat.h" /* WhiteHEAT specific commands */ 32 32 33 - #ifndef CMSPAR 34 - #define CMSPAR 0 35 - #endif 36 - 37 33 /* 38 34 * Version Information 39 35 */
+1
include/linux/serial_core.h
··· 232 232 int hw_stopped; /* sw-assisted CTS flow state */ 233 233 unsigned int mctrl; /* current modem ctrl settings */ 234 234 unsigned int timeout; /* character-based timeout */ 235 + unsigned int frame_time; /* frame timing in ns */ 235 236 unsigned int type; /* port type */ 236 237 const struct uart_ops *ops; 237 238 unsigned int custom_divisor;
+3
include/linux/serial_s3c.h
··· 256 256 #define APPLE_S5L_UCON_DEFAULT (S3C2410_UCON_TXIRQMODE | \ 257 257 S3C2410_UCON_RXIRQMODE | \ 258 258 S3C2410_UCON_RXFIFO_TOI) 259 + #define APPLE_S5L_UCON_MASK (APPLE_S5L_UCON_RXTO_ENA_MSK | \ 260 + APPLE_S5L_UCON_RXTHRESH_ENA_MSK | \ 261 + APPLE_S5L_UCON_TXTHRESH_ENA_MSK) 259 262 260 263 #define APPLE_S5L_UTRSTAT_RXTHRESH (1<<4) 261 264 #define APPLE_S5L_UTRSTAT_TXTHRESH (1<<5)
+65
include/uapi/asm-generic/termbits-common.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + #ifndef __ASM_GENERIC_TERMBITS_COMMON_H 3 + #define __ASM_GENERIC_TERMBITS_COMMON_H 4 + 5 + typedef unsigned char cc_t; 6 + typedef unsigned int speed_t; 7 + 8 + /* c_iflag bits */ 9 + #define IGNBRK 0x001 /* Ignore break condition */ 10 + #define BRKINT 0x002 /* Signal interrupt on break */ 11 + #define IGNPAR 0x004 /* Ignore characters with parity errors */ 12 + #define PARMRK 0x008 /* Mark parity and framing errors */ 13 + #define INPCK 0x010 /* Enable input parity check */ 14 + #define ISTRIP 0x020 /* Strip 8th bit off characters */ 15 + #define INLCR 0x040 /* Map NL to CR on input */ 16 + #define IGNCR 0x080 /* Ignore CR */ 17 + #define ICRNL 0x100 /* Map CR to NL on input */ 18 + #define IXANY 0x800 /* Any character will restart after stop */ 19 + 20 + /* c_oflag bits */ 21 + #define OPOST 0x01 /* Perform output processing */ 22 + #define OCRNL 0x08 23 + #define ONOCR 0x10 24 + #define ONLRET 0x20 25 + #define OFILL 0x40 26 + #define OFDEL 0x80 27 + 28 + /* c_cflag bit meaning */ 29 + /* Common CBAUD rates */ 30 + #define B0 0x00000000 /* hang up */ 31 + #define B50 0x00000001 32 + #define B75 0x00000002 33 + #define B110 0x00000003 34 + #define B134 0x00000004 35 + #define B150 0x00000005 36 + #define B200 0x00000006 37 + #define B300 0x00000007 38 + #define B600 0x00000008 39 + #define B1200 0x00000009 40 + #define B1800 0x0000000a 41 + #define B2400 0x0000000b 42 + #define B4800 0x0000000c 43 + #define B9600 0x0000000d 44 + #define B19200 0x0000000e 45 + #define B38400 0x0000000f 46 + #define EXTA B19200 47 + #define EXTB B38400 48 + 49 + #define CMSPAR 0x40000000 /* mark or space (stick) parity */ 50 + #define CRTSCTS 0x80000000 /* flow control */ 51 + 52 + #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ 53 + 54 + /* tcflow() ACTION argument and TCXONC use these */ 55 + #define TCOOFF 0 /* Suspend output */ 56 + #define TCOON 1 /* Restart suspended output */ 57 + #define TCIOFF 2 /* Send a STOP character */ 58 + #define TCION 3 /* Send a START character */ 59 + 60 + /* tcflush() QUEUE_SELECTOR argument and TCFLSH use these */ 61 + #define TCIFLUSH 0 /* Discard data received but not yet read */ 62 + #define TCOFLUSH 1 /* Discard data written but not yet sent */ 63 + #define TCIOFLUSH 2 /* Discard all pending data */ 64 + 65 + #endif /* __ASM_GENERIC_TERMBITS_COMMON_H */
+94 -145
include/uapi/asm-generic/termbits.h
··· 2 2 #ifndef __ASM_GENERIC_TERMBITS_H 3 3 #define __ASM_GENERIC_TERMBITS_H 4 4 5 - #include <linux/posix_types.h> 5 + #include <asm-generic/termbits-common.h> 6 6 7 - typedef unsigned char cc_t; 8 - typedef unsigned int speed_t; 9 7 typedef unsigned int tcflag_t; 10 8 11 9 #define NCCS 19 ··· 39 41 }; 40 42 41 43 /* c_cc characters */ 42 - #define VINTR 0 43 - #define VQUIT 1 44 - #define VERASE 2 45 - #define VKILL 3 46 - #define VEOF 4 47 - #define VTIME 5 48 - #define VMIN 6 49 - #define VSWTC 7 50 - #define VSTART 8 51 - #define VSTOP 9 52 - #define VSUSP 10 53 - #define VEOL 11 54 - #define VREPRINT 12 55 - #define VDISCARD 13 56 - #define VWERASE 14 57 - #define VLNEXT 15 58 - #define VEOL2 16 44 + #define VINTR 0 45 + #define VQUIT 1 46 + #define VERASE 2 47 + #define VKILL 3 48 + #define VEOF 4 49 + #define VTIME 5 50 + #define VMIN 6 51 + #define VSWTC 7 52 + #define VSTART 8 53 + #define VSTOP 9 54 + #define VSUSP 10 55 + #define VEOL 11 56 + #define VREPRINT 12 57 + #define VDISCARD 13 58 + #define VWERASE 14 59 + #define VLNEXT 15 60 + #define VEOL2 16 59 61 60 62 /* c_iflag bits */ 61 - #define IGNBRK 0000001 62 - #define BRKINT 0000002 63 - #define IGNPAR 0000004 64 - #define PARMRK 0000010 65 - #define INPCK 0000020 66 - #define ISTRIP 0000040 67 - #define INLCR 0000100 68 - #define IGNCR 0000200 69 - #define ICRNL 0000400 70 - #define IUCLC 0001000 71 - #define IXON 0002000 72 - #define IXANY 0004000 73 - #define IXOFF 0010000 74 - #define IMAXBEL 0020000 75 - #define IUTF8 0040000 63 + #define IUCLC 0x0200 64 + #define IXON 0x0400 65 + #define IXOFF 0x1000 66 + #define IMAXBEL 0x2000 67 + #define IUTF8 0x4000 76 68 77 69 /* c_oflag bits */ 78 - #define OPOST 0000001 79 - #define OLCUC 0000002 80 - #define ONLCR 0000004 81 - #define OCRNL 0000010 82 - #define ONOCR 0000020 83 - #define ONLRET 0000040 84 - #define OFILL 0000100 85 - #define OFDEL 0000200 86 - #define NLDLY 0000400 87 - #define NL0 0000000 88 - #define NL1 0000400 89 - #define CRDLY 0003000 90 - #define CR0 0000000 91 - #define CR1 0001000 92 - #define CR2 0002000 93 - #define CR3 0003000 94 - #define TABDLY 0014000 95 - #define TAB0 0000000 96 - #define TAB1 0004000 97 - #define TAB2 0010000 98 - #define TAB3 0014000 99 - #define XTABS 0014000 100 - #define BSDLY 0020000 101 - #define BS0 0000000 102 - #define BS1 0020000 103 - #define VTDLY 0040000 104 - #define VT0 0000000 105 - #define VT1 0040000 106 - #define FFDLY 0100000 107 - #define FF0 0000000 108 - #define FF1 0100000 70 + #define OLCUC 0x00002 71 + #define ONLCR 0x00004 72 + #define NLDLY 0x00100 73 + #define NL0 0x00000 74 + #define NL1 0x00100 75 + #define CRDLY 0x00600 76 + #define CR0 0x00000 77 + #define CR1 0x00200 78 + #define CR2 0x00400 79 + #define CR3 0x00600 80 + #define TABDLY 0x01800 81 + #define TAB0 0x00000 82 + #define TAB1 0x00800 83 + #define TAB2 0x01000 84 + #define TAB3 0x01800 85 + #define XTABS 0x01800 86 + #define BSDLY 0x02000 87 + #define BS0 0x00000 88 + #define BS1 0x02000 89 + #define VTDLY 0x04000 90 + #define VT0 0x00000 91 + #define VT1 0x04000 92 + #define FFDLY 0x08000 93 + #define FF0 0x00000 94 + #define FF1 0x08000 109 95 110 96 /* c_cflag bit meaning */ 111 - #define CBAUD 0010017 112 - #define B0 0000000 /* hang up */ 113 - #define B50 0000001 114 - #define B75 0000002 115 - #define B110 0000003 116 - #define B134 0000004 117 - #define B150 0000005 118 - #define B200 0000006 119 - #define B300 0000007 120 - #define B600 0000010 121 - #define B1200 0000011 122 - #define B1800 0000012 123 - #define B2400 0000013 124 - #define B4800 0000014 125 - #define B9600 0000015 126 - #define B19200 0000016 127 - #define B38400 0000017 128 - #define EXTA B19200 129 - #define EXTB B38400 130 - #define CSIZE 0000060 131 - #define CS5 0000000 132 - #define CS6 0000020 133 - #define CS7 0000040 134 - #define CS8 0000060 135 - #define CSTOPB 0000100 136 - #define CREAD 0000200 137 - #define PARENB 0000400 138 - #define PARODD 0001000 139 - #define HUPCL 0002000 140 - #define CLOCAL 0004000 141 - #define CBAUDEX 0010000 142 - #define BOTHER 0010000 143 - #define B57600 0010001 144 - #define B115200 0010002 145 - #define B230400 0010003 146 - #define B460800 0010004 147 - #define B500000 0010005 148 - #define B576000 0010006 149 - #define B921600 0010007 150 - #define B1000000 0010010 151 - #define B1152000 0010011 152 - #define B1500000 0010012 153 - #define B2000000 0010013 154 - #define B2500000 0010014 155 - #define B3000000 0010015 156 - #define B3500000 0010016 157 - #define B4000000 0010017 158 - #define CIBAUD 002003600000 /* input baud rate */ 159 - #define CMSPAR 010000000000 /* mark or space (stick) parity */ 160 - #define CRTSCTS 020000000000 /* flow control */ 161 - 162 - #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ 97 + #define CBAUD 0x0000100f 98 + #define CSIZE 0x00000030 99 + #define CS5 0x00000000 100 + #define CS6 0x00000010 101 + #define CS7 0x00000020 102 + #define CS8 0x00000030 103 + #define CSTOPB 0x00000040 104 + #define CREAD 0x00000080 105 + #define PARENB 0x00000100 106 + #define PARODD 0x00000200 107 + #define HUPCL 0x00000400 108 + #define CLOCAL 0x00000800 109 + #define CBAUDEX 0x00001000 110 + #define BOTHER 0x00001000 111 + #define B57600 0x00001001 112 + #define B115200 0x00001002 113 + #define B230400 0x00001003 114 + #define B460800 0x00001004 115 + #define B500000 0x00001005 116 + #define B576000 0x00001006 117 + #define B921600 0x00001007 118 + #define B1000000 0x00001008 119 + #define B1152000 0x00001009 120 + #define B1500000 0x0000100a 121 + #define B2000000 0x0000100b 122 + #define B2500000 0x0000100c 123 + #define B3000000 0x0000100d 124 + #define B3500000 0x0000100e 125 + #define B4000000 0x0000100f 126 + #define CIBAUD 0x100f0000 /* input baud rate */ 163 127 164 128 /* c_lflag bits */ 165 - #define ISIG 0000001 166 - #define ICANON 0000002 167 - #define XCASE 0000004 168 - #define ECHO 0000010 169 - #define ECHOE 0000020 170 - #define ECHOK 0000040 171 - #define ECHONL 0000100 172 - #define NOFLSH 0000200 173 - #define TOSTOP 0000400 174 - #define ECHOCTL 0001000 175 - #define ECHOPRT 0002000 176 - #define ECHOKE 0004000 177 - #define FLUSHO 0010000 178 - #define PENDIN 0040000 179 - #define IEXTEN 0100000 180 - #define EXTPROC 0200000 181 - 182 - /* tcflow() and TCXONC use these */ 183 - #define TCOOFF 0 184 - #define TCOON 1 185 - #define TCIOFF 2 186 - #define TCION 3 187 - 188 - /* tcflush() and TCFLSH use these */ 189 - #define TCIFLUSH 0 190 - #define TCOFLUSH 1 191 - #define TCIOFLUSH 2 129 + #define ISIG 0x00001 130 + #define ICANON 0x00002 131 + #define XCASE 0x00004 132 + #define ECHO 0x00008 133 + #define ECHOE 0x00010 134 + #define ECHOK 0x00020 135 + #define ECHONL 0x00040 136 + #define NOFLSH 0x00080 137 + #define TOSTOP 0x00100 138 + #define ECHOCTL 0x00200 139 + #define ECHOPRT 0x00400 140 + #define ECHOKE 0x00800 141 + #define FLUSHO 0x01000 142 + #define PENDIN 0x04000 143 + #define IEXTEN 0x08000 144 + #define EXTPROC 0x10000 192 145 193 146 /* tcsetattr uses these */ 194 147 #define TCSANOW 0