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

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

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

Once again, Jiri and Ilpo have done a number of core vt and tty/serial
layer cleanups that were much needed and appreciated. Other than that,
it's just a bunch of little tty/serial driver updates:

- qcom-geni-serial driver updates

- liteuart driver updates

- hvcs driver cleanups

- n_gsm updates and additions for new features

- more 8250 device support added

- fpga/dfl update and additions

- imx serial driver updates

- fsl_lpuart updates

- other tiny fixes and updates for serial drivers

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

* tag 'tty-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (143 commits)
tty: n_gsm: add keep alive support
serial: imx: remove a redundant check
dt-bindings: serial: snps-dw-apb-uart: add dma & dma-names properties
soc: qcom: geni-se: Move qcom-geni-se.h to linux/soc/qcom/geni-se.h
tty: n_gsm: add TIOCMIWAIT support
tty: n_gsm: add RING/CD control support
tty: n_gsm: mark unusable ioctl structure fields accordingly
serial: imx: get rid of registers shadowing
serial: imx: refine local variables in rxint()
serial: imx: stop using USR2 in FIFO reading loop
serial: imx: remove redundant USR2 read from FIFO reading loop
serial: imx: do not break from FIFO reading loop prematurely
serial: imx: do not sysrq broken chars
serial: imx: work-around for hardware RX flood
serial: imx: factor-out common code to imx_uart_soft_reset()
serial: 8250_pci1xxxx: Add power management functions to quad-uart driver
serial: 8250_pci1xxxx: Add RS485 support to quad-uart driver
serial: 8250_pci1xxxx: Add driver for quad-uart support
serial: 8250_pci: Add serial8250_pci_setup_port definition in 8250_pcilib.c
tty: pcn_uart: fix memory leak with using debugfs_lookup()
...

+2927 -1302
+7 -5
Documentation/admin-guide/kernel-parameters.txt
··· 1172 1172 specified, the serial port must already be setup and 1173 1173 configured. 1174 1174 1175 - uart[8250],io,<addr>[,options] 1176 - uart[8250],mmio,<addr>[,options] 1177 - uart[8250],mmio32,<addr>[,options] 1178 - uart[8250],mmio32be,<addr>[,options] 1175 + uart[8250],io,<addr>[,options[,uartclk]] 1176 + uart[8250],mmio,<addr>[,options[,uartclk]] 1177 + uart[8250],mmio32,<addr>[,options[,uartclk]] 1178 + uart[8250],mmio32be,<addr>[,options[,uartclk]] 1179 1179 uart[8250],0x<addr>[,options] 1180 1180 Start an early, polled-mode console on the 8250/16550 1181 1181 UART at the specified I/O port or MMIO address. ··· 1184 1184 If none of [io|mmio|mmio32|mmio32be], <addr> is assumed 1185 1185 to be equivalent to 'mmio'. 'options' are specified 1186 1186 in the same format described for "console=ttyS<n>"; if 1187 - unspecified, the h/w is not initialized. 1187 + unspecified, the h/w is not initialized. 'uartclk' is 1188 + the uart clock frequency; if unspecified, it is set 1189 + to 'BASE_BAUD' * 16. 1188 1190 1189 1191 pl011,<addr> 1190 1192 pl011,mmio32,<addr>
+7 -3
Documentation/devicetree/bindings/serial/8250.yaml
··· 62 62 - const: mrvl,pxa-uart 63 63 - const: nuvoton,wpcm450-uart 64 64 - const: nuvoton,npcm750-uart 65 - - const: nuvoton,npcm845-uart 66 65 - const: nvidia,tegra20-uart 67 66 - const: nxp,lpc3220-uart 68 67 - items: ··· 91 92 - enum: 92 93 - ns16550 # Deprecated, unless the FIFO really is broken 93 94 - ns16550a 95 + - items: 96 + - enum: 97 + - nuvoton,npcm845-uart 98 + - const: nuvoton,npcm750-uart 94 99 - items: 95 100 - enum: 96 101 - ralink,mt7620a-uart ··· 203 200 deprecated: true 204 201 205 202 aspeed,lpc-io-reg: 206 - $ref: '/schemas/types.yaml#/definitions/uint32' 203 + $ref: /schemas/types.yaml#/definitions/uint32-array 204 + maxItems: 1 207 205 description: | 208 206 The VUART LPC address. Only applicable to aspeed,ast2500-vuart. 209 207 210 208 aspeed,lpc-interrupts: 211 - $ref: "/schemas/types.yaml#/definitions/uint32-array" 209 + $ref: /schemas/types.yaml#/definitions/uint32-array 212 210 minItems: 2 213 211 maxItems: 2 214 212 description: |
+9 -14
Documentation/devicetree/bindings/serial/8250_omap.yaml
··· 70 70 dsr-gpios: true 71 71 rng-gpios: true 72 72 dcd-gpios: true 73 - rs485-rts-delay: true 74 - rs485-rts-active-low: true 75 - rs485-rx-during-tx: true 76 - rs485-rts-active-high: true 77 - linux,rs485-enabled-at-boot-time: true 78 73 rts-gpio: true 79 74 power-domains: true 80 75 clock-frequency: true ··· 104 109 105 110 examples: 106 111 - | 107 - serial@49042000 { 108 - compatible = "ti,omap3-uart"; 109 - reg = <0x49042000 0x400>; 110 - interrupts = <80>; 111 - dmas = <&sdma 81 &sdma 82>; 112 - dma-names = "tx", "rx"; 113 - ti,hwmods = "uart4"; 114 - clock-frequency = <48000000>; 115 - }; 112 + serial@49042000 { 113 + compatible = "ti,omap3-uart"; 114 + reg = <0x49042000 0x400>; 115 + interrupts = <80>; 116 + dmas = <&sdma 81 &sdma 82>; 117 + dma-names = "tx", "rx"; 118 + ti,hwmods = "uart4"; 119 + clock-frequency = <48000000>; 120 + };
+9 -6
Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
··· 19 19 is active since power-on and does not need any clock gating and is usable 20 20 as very early serial console. 21 21 22 + allOf: 23 + - $ref: serial.yaml# 24 + 22 25 properties: 23 26 compatible: 24 27 oneOf: ··· 72 69 - clocks 73 70 - clock-names 74 71 75 - additionalProperties: false 72 + unevaluatedProperties: false 76 73 77 74 examples: 78 75 - | 79 76 serial@84c0 { 80 - compatible = "amlogic,meson-gx-uart"; 81 - reg = <0x84c0 0x14>; 82 - interrupts = <26>; 83 - clocks = <&xtal>, <&pclk>, <&xtal>; 84 - clock-names = "xtal", "pclk", "baud"; 77 + compatible = "amlogic,meson-gx-uart"; 78 + reg = <0x84c0 0x14>; 79 + interrupts = <26>; 80 + clocks = <&xtal>, <&pclk>, <&xtal>; 81 + clock-names = "xtal", "pclk", "baud"; 85 82 };
+19 -8
Documentation/devicetree/bindings/serial/cdns,uart.yaml
··· 9 9 maintainers: 10 10 - Michal Simek <michal.simek@xilinx.com> 11 11 12 - allOf: 13 - - $ref: /schemas/serial.yaml# 14 - 15 12 properties: 16 13 compatible: 17 14 oneOf: ··· 43 46 port does not use this pin. 44 47 type: boolean 45 48 49 + power-domains: 50 + maxItems: 1 51 + 46 52 required: 47 53 - compatible 48 54 - reg ··· 53 53 - clocks 54 54 - clock-names 55 55 56 + allOf: 57 + - $ref: serial.yaml# 58 + - if: 59 + properties: 60 + compatible: 61 + contains: 62 + const: cdns,uart-r1p8 63 + then: 64 + properties: 65 + power-domains: false 66 + 56 67 unevaluatedProperties: false 57 68 58 69 examples: 59 70 - | 60 71 uart0: serial@e0000000 { 61 - compatible = "xlnx,xuartps", "cdns,uart-r1p8"; 62 - clocks = <&clkc 23>, <&clkc 40>; 63 - clock-names = "uart_clk", "pclk"; 64 - reg = <0xE0000000 0x1000>; 65 - interrupts = <0 27 4>; 72 + compatible = "xlnx,xuartps", "cdns,uart-r1p8"; 73 + clocks = <&clkc 23>, <&clkc 40>; 74 + clock-names = "uart_clk", "pclk"; 75 + reg = <0xe0000000 0x1000>; 76 + interrupts = <0 27 4>; 66 77 };
+1 -1
Documentation/devicetree/bindings/serial/fsl,s32-linflexuart.yaml
··· 16 16 - Chester Lin <clin@suse.com> 17 17 18 18 allOf: 19 - - $ref: "serial.yaml" 19 + - $ref: serial.yaml# 20 20 21 21 properties: 22 22 compatible:
+2 -9
Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml
··· 10 10 - Fabio Estevam <festevam@gmail.com> 11 11 12 12 allOf: 13 - - $ref: "serial.yaml" 14 - - $ref: "rs485.yaml" 13 + - $ref: serial.yaml# 14 + - $ref: rs485.yaml# 15 15 16 16 properties: 17 17 compatible: ··· 82 82 When not being configured the system will use default settings, which 83 83 are sensible for most use cases. If you need low latency processing on 84 84 slow connections this needs to be configured appropriately. 85 - 86 - uart-has-rtscts: true 87 - 88 - rs485-rts-delay: true 89 - rs485-rts-active-low: true 90 - rs485-rx-during-tx: true 91 - linux,rs485-enabled-at-boot-time: true 92 85 93 86 required: 94 87 - compatible
+2 -4
Documentation/devicetree/bindings/serial/fsl-lpuart.yaml
··· 10 10 - Fugang Duan <fugang.duan@nxp.com> 11 11 12 12 allOf: 13 - - $ref: "rs485.yaml" 13 + - $ref: rs485.yaml# 14 + - $ref: serial.yaml# 14 15 15 16 properties: 16 17 compatible: ··· 64 63 items: 65 64 - const: rx 66 65 - const: tx 67 - 68 - rs485-rts-active-low: true 69 - linux,rs485-enabled-at-boot-time: true 70 66 71 67 required: 72 68 - compatible
+1 -1
Documentation/devicetree/bindings/serial/fsl-mxs-auart.yaml
··· 10 10 - Fabio Estevam <festevam@gmail.com> 11 11 12 12 allOf: 13 - - $ref: "serial.yaml" 13 + - $ref: serial.yaml# 14 14 15 15 properties: 16 16 compatible:
+1
Documentation/devicetree/bindings/serial/pl011.yaml
··· 10 10 - Rob Herring <robh@kernel.org> 11 11 12 12 allOf: 13 + - $ref: /schemas/arm/primecell.yaml# 13 14 - $ref: serial.yaml# 14 15 15 16 # Need a custom select here or 'arm,primecell' will match on lots of nodes
-25
Documentation/devicetree/bindings/serial/qcom,msm-uart.txt
··· 1 - * MSM Serial UART 2 - 3 - The MSM serial UART hardware is designed for low-speed use cases where a 4 - dma-engine isn't needed. From a software perspective it's mostly compatible 5 - with the MSM serial UARTDM except that it only supports reading and writing one 6 - character at a time. 7 - 8 - Required properties: 9 - - compatible: Should contain "qcom,msm-uart" 10 - - reg: Should contain UART register location and length. 11 - - interrupts: Should contain UART interrupt. 12 - - clocks: Should contain the core clock. 13 - - clock-names: Should be "core". 14 - 15 - Example: 16 - 17 - A uart device at 0xa9c00000 with interrupt 11. 18 - 19 - serial@a9c00000 { 20 - compatible = "qcom,msm-uart"; 21 - reg = <0xa9c00000 0x1000>; 22 - interrupts = <11>; 23 - clocks = <&uart_cxc>; 24 - clock-names = "core"; 25 - };
+56
Documentation/devicetree/bindings/serial/qcom,msm-uart.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/serial/qcom,msm-uart.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm MSM SoC Serial UART 8 + 9 + maintainers: 10 + - Bjorn Andersson <andersson@kernel.org> 11 + - Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> 12 + 13 + description: 14 + The MSM serial UART hardware is designed for low-speed use cases where a 15 + dma-engine isn't needed. From a software perspective it's mostly compatible 16 + with the MSM serial UARTDM except that it only supports reading and writing 17 + one character at a time. 18 + 19 + properties: 20 + compatible: 21 + const: qcom,msm-uart 22 + 23 + clocks: 24 + maxItems: 1 25 + 26 + clock-names: 27 + items: 28 + - const: core 29 + 30 + interrupts: 31 + maxItems: 1 32 + 33 + reg: 34 + maxItems: 1 35 + 36 + required: 37 + - compatible 38 + - clock-names 39 + - clocks 40 + - interrupts 41 + - reg 42 + 43 + unevaluatedProperties: false 44 + 45 + allOf: 46 + - $ref: /schemas/serial/serial.yaml# 47 + 48 + examples: 49 + - | 50 + serial@a9c00000 { 51 + compatible = "qcom,msm-uart"; 52 + reg = <0xa9c00000 0x1000>; 53 + interrupts = <11>; 54 + clocks = <&uart_cxc>; 55 + clock-names = "core"; 56 + };
+5 -5
Documentation/devicetree/bindings/serial/renesas,em-uart.yaml
··· 66 66 - | 67 67 #include <dt-bindings/interrupt-controller/arm-gic.h> 68 68 uart0: serial@e1020000 { 69 - compatible = "renesas,em-uart"; 70 - reg = <0xe1020000 0x38>; 71 - interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>; 72 - clocks = <&usia_u0_sclk>; 73 - clock-names = "sclk"; 69 + compatible = "renesas,em-uart"; 70 + reg = <0xe1020000 0x38>; 71 + interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>; 72 + clocks = <&usia_u0_sclk>; 73 + clock-names = "sclk"; 74 74 };
+13 -13
Documentation/devicetree/bindings/serial/renesas,hscif.yaml
··· 131 131 #include <dt-bindings/interrupt-controller/arm-gic.h> 132 132 #include <dt-bindings/power/r8a7795-sysc.h> 133 133 aliases { 134 - serial1 = &hscif1; 134 + serial1 = &hscif1; 135 135 }; 136 136 137 137 hscif1: serial@e6550000 { 138 - compatible = "renesas,hscif-r8a7795", "renesas,rcar-gen3-hscif", 139 - "renesas,hscif"; 140 - reg = <0xe6550000 96>; 141 - interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>; 142 - clocks = <&cpg CPG_MOD 519>, <&cpg CPG_CORE R8A7795_CLK_S3D1>, 143 - <&scif_clk>; 144 - clock-names = "fck", "brg_int", "scif_clk"; 145 - dmas = <&dmac1 0x33>, <&dmac1 0x32>, <&dmac2 0x33>, <&dmac2 0x32>; 146 - dma-names = "tx", "rx", "tx", "rx"; 147 - power-domains = <&sysc R8A7795_PD_ALWAYS_ON>; 148 - resets = <&cpg 519>; 149 - uart-has-rtscts; 138 + compatible = "renesas,hscif-r8a7795", "renesas,rcar-gen3-hscif", 139 + "renesas,hscif"; 140 + reg = <0xe6550000 96>; 141 + interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>; 142 + clocks = <&cpg CPG_MOD 519>, <&cpg CPG_CORE R8A7795_CLK_S3D1>, 143 + <&scif_clk>; 144 + clock-names = "fck", "brg_int", "scif_clk"; 145 + dmas = <&dmac1 0x33>, <&dmac1 0x32>, <&dmac2 0x33>, <&dmac2 0x32>; 146 + dma-names = "tx", "rx", "tx", "rx"; 147 + power-domains = <&sysc R8A7795_PD_ALWAYS_ON>; 148 + resets = <&cpg 519>; 149 + uart-has-rtscts; 150 150 };
+12 -12
Documentation/devicetree/bindings/serial/renesas,sci.yaml
··· 91 91 #include <dt-bindings/interrupt-controller/arm-gic.h> 92 92 93 93 aliases { 94 - serial0 = &sci0; 94 + serial0 = &sci0; 95 95 }; 96 96 97 97 sci0: serial@1004d000 { 98 - compatible = "renesas,r9a07g044-sci", "renesas,sci"; 99 - reg = <0x1004d000 0x400>; 100 - interrupts = <GIC_SPI 405 IRQ_TYPE_LEVEL_HIGH>, 101 - <GIC_SPI 406 IRQ_TYPE_LEVEL_HIGH>, 102 - <GIC_SPI 407 IRQ_TYPE_LEVEL_HIGH>, 103 - <GIC_SPI 408 IRQ_TYPE_LEVEL_HIGH>; 104 - interrupt-names = "eri", "rxi", "txi", "tei"; 105 - clocks = <&cpg CPG_MOD R9A07G044_SCI0_CLKP>; 106 - clock-names = "fck"; 107 - power-domains = <&cpg>; 108 - resets = <&cpg R9A07G044_SCI0_RST>; 98 + compatible = "renesas,r9a07g044-sci", "renesas,sci"; 99 + reg = <0x1004d000 0x400>; 100 + interrupts = <GIC_SPI 405 IRQ_TYPE_LEVEL_HIGH>, 101 + <GIC_SPI 406 IRQ_TYPE_LEVEL_HIGH>, 102 + <GIC_SPI 407 IRQ_TYPE_LEVEL_HIGH>, 103 + <GIC_SPI 408 IRQ_TYPE_LEVEL_HIGH>; 104 + interrupt-names = "eri", "rxi", "txi", "tei"; 105 + clocks = <&cpg CPG_MOD R9A07G044_SCI0_CLKP>; 106 + clock-names = "fck"; 107 + power-domains = <&cpg>; 108 + resets = <&cpg R9A07G044_SCI0_RST>; 109 109 };
+12 -12
Documentation/devicetree/bindings/serial/renesas,scif.yaml
··· 180 180 #include <dt-bindings/interrupt-controller/arm-gic.h> 181 181 #include <dt-bindings/power/r8a7791-sysc.h> 182 182 aliases { 183 - serial0 = &scif0; 183 + serial0 = &scif0; 184 184 }; 185 185 186 186 scif0: serial@e6e60000 { 187 - compatible = "renesas,scif-r8a7791", "renesas,rcar-gen2-scif", 188 - "renesas,scif"; 189 - reg = <0xe6e60000 64>; 190 - interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>; 191 - clocks = <&cpg CPG_MOD 721>, <&cpg CPG_CORE R8A7791_CLK_ZS>, 192 - <&scif_clk>; 193 - clock-names = "fck", "brg_int", "scif_clk"; 194 - dmas = <&dmac0 0x29>, <&dmac0 0x2a>, <&dmac1 0x29>, <&dmac1 0x2a>; 195 - dma-names = "tx", "rx", "tx", "rx"; 196 - power-domains = <&sysc R8A7791_PD_ALWAYS_ON>; 197 - resets = <&cpg 721>; 187 + compatible = "renesas,scif-r8a7791", "renesas,rcar-gen2-scif", 188 + "renesas,scif"; 189 + reg = <0xe6e60000 64>; 190 + interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>; 191 + clocks = <&cpg CPG_MOD 721>, <&cpg CPG_CORE R8A7791_CLK_ZS>, 192 + <&scif_clk>; 193 + clock-names = "fck", "brg_int", "scif_clk"; 194 + dmas = <&dmac0 0x29>, <&dmac0 0x2a>, <&dmac1 0x29>, <&dmac1 0x2a>; 195 + dma-names = "tx", "rx", "tx", "rx"; 196 + power-domains = <&sysc R8A7791_PD_ALWAYS_ON>; 197 + resets = <&cpg 721>; 198 198 };
+11 -11
Documentation/devicetree/bindings/serial/renesas,scifa.yaml
··· 95 95 #include <dt-bindings/interrupt-controller/arm-gic.h> 96 96 #include <dt-bindings/power/r8a7790-sysc.h> 97 97 aliases { 98 - serial0 = &scifa0; 98 + serial0 = &scifa0; 99 99 }; 100 100 101 101 scifa0: serial@e6c40000 { 102 - compatible = "renesas,scifa-r8a7790", "renesas,rcar-gen2-scifa", 103 - "renesas,scifa"; 104 - reg = <0xe6c40000 64>; 105 - interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>; 106 - clocks = <&cpg CPG_MOD 204>; 107 - clock-names = "fck"; 108 - power-domains = <&sysc R8A7790_PD_ALWAYS_ON>; 109 - resets = <&cpg 204>; 110 - dmas = <&dmac0 0x21>, <&dmac0 0x22>, <&dmac1 0x21>, <&dmac1 0x22>; 111 - dma-names = "tx", "rx", "tx", "rx"; 102 + compatible = "renesas,scifa-r8a7790", "renesas,rcar-gen2-scifa", 103 + "renesas,scifa"; 104 + reg = <0xe6c40000 64>; 105 + interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>; 106 + clocks = <&cpg CPG_MOD 204>; 107 + clock-names = "fck"; 108 + power-domains = <&sysc R8A7790_PD_ALWAYS_ON>; 109 + resets = <&cpg 204>; 110 + dmas = <&dmac0 0x21>, <&dmac0 0x22>, <&dmac1 0x21>, <&dmac1 0x22>; 111 + dma-names = "tx", "rx", "tx", "rx"; 112 112 };
+6 -6
Documentation/devicetree/bindings/serial/renesas,scifb.yaml
··· 94 94 #include <dt-bindings/clock/r8a7740-clock.h> 95 95 #include <dt-bindings/interrupt-controller/arm-gic.h> 96 96 scifb: serial@e6c30000 { 97 - compatible = "renesas,scifb-r8a7740", "renesas,scifb"; 98 - reg = <0xe6c30000 0x100>; 99 - interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; 100 - clocks = <&mstp2_clks R8A7740_CLK_SCIFB>; 101 - clock-names = "fck"; 102 - power-domains = <&pd_a3sp>; 97 + compatible = "renesas,scifb-r8a7740", "renesas,scifb"; 98 + reg = <0xe6c30000 0x100>; 99 + interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; 100 + clocks = <&mstp2_clks R8A7740_CLK_SCIFB>; 101 + clock-names = "fck"; 102 + power-domains = <&pd_a3sp>; 103 103 };
+6
Documentation/devicetree/bindings/serial/rs485.yaml
··· 51 51 description: GPIO pin to enable RS485 bus termination. 52 52 maxItems: 1 53 53 54 + rs485-rx-during-tx-gpios: 55 + description: Output GPIO pin that sets the state of rs485-rx-during-tx. This 56 + signal can be used to control the RX part of an RS485 transceiver. Thereby 57 + the active state enables RX during TX. 58 + maxItems: 1 59 + 54 60 additionalProperties: true 55 61 56 62 ...
+8 -8
Documentation/devicetree/bindings/serial/serial.yaml
··· 141 141 examples: 142 142 - | 143 143 serial@1234 { 144 - compatible = "ns16550a"; 145 - reg = <0x1234 0x20>; 146 - interrupts = <1>; 144 + compatible = "ns16550a"; 145 + reg = <0x1234 0x20>; 146 + interrupts = <1>; 147 147 148 - bluetooth { 149 - compatible = "brcm,bcm4330-bt"; 150 - interrupt-parent = <&gpio>; 151 - interrupts = <10>; 152 - }; 148 + bluetooth { 149 + compatible = "brcm,bcm4330-bt"; 150 + interrupt-parent = <&gpio>; 151 + interrupts = <10>; 152 + }; 153 153 };
+3 -3
Documentation/devicetree/bindings/serial/sifive-serial.yaml
··· 53 53 54 54 examples: 55 55 - | 56 - #include <dt-bindings/clock/sifive-fu540-prci.h> 57 - serial@10010000 { 56 + #include <dt-bindings/clock/sifive-fu540-prci.h> 57 + serial@10010000 { 58 58 compatible = "sifive,fu540-c000-uart", "sifive,uart0"; 59 59 interrupt-parent = <&plic0>; 60 60 interrupts = <80>; 61 61 reg = <0x10010000 0x1000>; 62 62 clocks = <&prci FU540_PRCI_CLK_TLCLK>; 63 - }; 63 + }; 64 64 65 65 ...
+8
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
··· 67 67 - const: baudclk 68 68 - const: apb_pclk 69 69 70 + dmas: 71 + minItems: 2 72 + 73 + dma-names: 74 + items: 75 + - const: rx 76 + - const: tx 77 + 70 78 snps,uart-16550-compatible: 71 79 description: reflects the value of UART_16550_COMPATIBLE configuration 72 80 parameter. Define this if your UART does not implement the busy functionality.
-7
Documentation/devicetree/bindings/serial/st,stm32-uart.yaml
··· 35 35 description: enable hardware flow control (deprecated) 36 36 $ref: /schemas/types.yaml#/definitions/flag 37 37 38 - uart-has-rtscts: true 39 - 40 38 rx-tx-swap: true 41 39 42 40 dmas: ··· 57 59 rts-gpios: true 58 60 59 61 wakeup-source: true 60 - 61 - rs485-rts-delay: true 62 - rs485-rts-active-low: true 63 - linux,rs485-enabled-at-boot-time: true 64 - rs485-rx-during-tx: true 65 62 66 63 rx-threshold: 67 64 description:
+3 -3
Documentation/devicetree/bindings/serial/xlnx,opb-uartlite.yaml
··· 63 63 - xlnx,use-parity 64 64 65 65 allOf: 66 - - $ref: /schemas/serial.yaml# 66 + - $ref: serial.yaml# 67 67 - if: 68 68 properties: 69 69 xlnx,use-parity: ··· 76 76 77 77 examples: 78 78 - | 79 - serial@800c0000 { 79 + serial@800c0000 { 80 80 compatible = "xlnx,xps-uartlite-1.00.a"; 81 81 reg = <0x800c0000 0x10000>; 82 82 interrupts = <0x0 0x6e 0x1>; ··· 84 84 current-speed = <115200>; 85 85 xlnx,data-bits = <8>; 86 86 xlnx,use-parity = <0>; 87 - }; 87 + }; 88 88 ...
+19
Documentation/driver-api/tty/n_gsm.rst
··· 25 25 #. Switch the serial line to using the n_gsm line discipline by using 26 26 ``TIOCSETD`` ioctl. 27 27 28 + #. Configure the mux using ``GSMIOC_GETCONF_EXT``/``GSMIOC_SETCONF_EXT`` ioctl if needed. 29 + 28 30 #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl. 29 31 30 32 #. Obtain base gsmtty number for the used serial port. ··· 44 42 45 43 int ldisc = N_GSM0710; 46 44 struct gsm_config c; 45 + struct gsm_config_ext ce; 47 46 struct termios configuration; 48 47 uint32_t first; 49 48 ··· 65 62 /* use n_gsm line discipline */ 66 63 ioctl(fd, TIOCSETD, &ldisc); 67 64 65 + /* get n_gsm extended configuration */ 66 + ioctl(fd, GSMIOC_GETCONF_EXT, &ce); 67 + /* use keep-alive once every 5s for modem connection supervision */ 68 + ce.keep_alive = 500; 69 + /* set the new extended configuration */ 70 + ioctl(fd, GSMIOC_SETCONF_EXT, &ce); 68 71 /* get n_gsm configuration */ 69 72 ioctl(fd, GSMIOC_GETCONF, &c); 70 73 /* we are initiator and need encoding 0 (basic) */ ··· 115 106 #. Switch the serial line to using the *n_gsm* line discipline by using 116 107 ``TIOCSETD`` ioctl. 117 108 109 + #. Configure the mux using ``GSMIOC_GETCONF_EXT``/``GSMIOC_SETCONF_EXT`` 110 + ioctl if needed. 111 + 118 112 #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl. 119 113 120 114 #. Obtain base gsmtty number for the used serial port:: ··· 131 119 132 120 int ldisc = N_GSM0710; 133 121 struct gsm_config c; 122 + struct gsm_config_ext ce; 134 123 struct termios configuration; 135 124 uint32_t first; 136 125 ··· 145 132 /* use n_gsm line discipline */ 146 133 ioctl(fd, TIOCSETD, &ldisc); 147 134 135 + /* get n_gsm extended configuration */ 136 + ioctl(fd, GSMIOC_GETCONF_EXT, &ce); 137 + /* use keep-alive once every 5s for peer connection supervision */ 138 + ce.keep_alive = 500; 139 + /* set the new extended configuration */ 140 + ioctl(fd, GSMIOC_SETCONF_EXT, &ce); 148 141 /* get n_gsm configuration */ 149 142 ioctl(fd, GSMIOC_GETCONF, &c); 150 143 /* we are requester and need encoding 0 (basic) */
+119
Documentation/fpga/dfl.rst
··· 75 75 and can be implemented in register regions of any FPGA device. 76 76 77 77 78 + Device Feature Header - Version 0 79 + ================================= 80 + Version 0 (DFHv0) is the original version of the Device Feature Header. 81 + All multi-byte quantities in DFHv0 are little-endian. 82 + The format of DFHv0 is shown below:: 83 + 84 + +-----------------------------------------------------------------------+ 85 + |63 Type 60|59 DFH VER 52|51 Rsvd 41|40 EOL|39 Next 16|15 REV 12|11 ID 0| 0x00 86 + +-----------------------------------------------------------------------+ 87 + |63 GUID_L 0| 0x08 88 + +-----------------------------------------------------------------------+ 89 + |63 GUID_H 0| 0x10 90 + +-----------------------------------------------------------------------+ 91 + 92 + - Offset 0x00 93 + 94 + * Type - The type of DFH (e.g. FME, AFU, or private feature). 95 + * DFH VER - The version of the DFH. 96 + * Rsvd - Currently unused. 97 + * EOL - Set if the DFH is the end of the Device Feature List (DFL). 98 + * Next - The offset in bytes of the next DFH in the DFL from the DFH start, 99 + and the start of a DFH must be aligned to an 8 byte boundary. 100 + If EOL is set, Next is the size of MMIO of the last feature in the list. 101 + * REV - The revision of the feature associated with this header. 102 + * ID - The feature ID if Type is private feature. 103 + 104 + - Offset 0x08 105 + 106 + * GUID_L - Least significant 64 bits of a 128-bit Globally Unique Identifier 107 + (present only if Type is FME or AFU). 108 + 109 + - Offset 0x10 110 + 111 + * GUID_H - Most significant 64 bits of a 128-bit Globally Unique Identifier 112 + (present only if Type is FME or AFU). 113 + 114 + 115 + Device Feature Header - Version 1 116 + ================================= 117 + Version 1 (DFHv1) of the Device Feature Header adds the following functionality: 118 + 119 + * Provides a standardized mechanism for features to describe 120 + parameters/capabilities to software. 121 + * Standardize the use of a GUID for all DFHv1 types. 122 + * Decouples the DFH location from the register space of the feature itself. 123 + 124 + All multi-byte quantities in DFHv1 are little-endian. 125 + The format of Version 1 of the Device Feature Header (DFH) is shown below:: 126 + 127 + +-----------------------------------------------------------------------+ 128 + |63 Type 60|59 DFH VER 52|51 Rsvd 41|40 EOL|39 Next 16|15 REV 12|11 ID 0| 0x00 129 + +-----------------------------------------------------------------------+ 130 + |63 GUID_L 0| 0x08 131 + +-----------------------------------------------------------------------+ 132 + |63 GUID_H 0| 0x10 133 + +-----------------------------------------------------------------------+ 134 + |63 Reg Address/Offset 1| Rel 0| 0x18 135 + +-----------------------------------------------------------------------+ 136 + |63 Reg Size 32|Params 31|30 Group 16|15 Instance 0| 0x20 137 + +-----------------------------------------------------------------------+ 138 + |63 Next 35|34RSV33|EOP32|31 Param Version 16|15 Param ID 0| 0x28 139 + +-----------------------------------------------------------------------+ 140 + |63 Parameter Data 0| 0x30 141 + +-----------------------------------------------------------------------+ 142 + 143 + ... 144 + 145 + +-----------------------------------------------------------------------+ 146 + |63 Next 35|34RSV33|EOP32|31 Param Version 16|15 Param ID 0| 147 + +-----------------------------------------------------------------------+ 148 + |63 Parameter Data 0| 149 + +-----------------------------------------------------------------------+ 150 + 151 + - Offset 0x00 152 + 153 + * Type - The type of DFH (e.g. FME, AFU, or private feature). 154 + * DFH VER - The version of the DFH. 155 + * Rsvd - Currently unused. 156 + * EOL - Set if the DFH is the end of the Device Feature List (DFL). 157 + * Next - The offset in bytes of the next DFH in the DFL from the DFH start, 158 + and the start of a DFH must be aligned to an 8 byte boundary. 159 + If EOL is set, Next is the size of MMIO of the last feature in the list. 160 + * REV - The revision of the feature associated with this header. 161 + * ID - The feature ID if Type is private feature. 162 + 163 + - Offset 0x08 164 + 165 + * GUID_L - Least significant 64 bits of a 128-bit Globally Unique Identifier. 166 + 167 + - Offset 0x10 168 + 169 + * GUID_H - Most significant 64 bits of a 128-bit Globally Unique Identifier. 170 + 171 + - Offset 0x18 172 + 173 + * Reg Address/Offset - If Rel bit is set, then the value is the high 63 bits 174 + of a 16-bit aligned absolute address of the feature's registers. Otherwise 175 + the value is the offset from the start of the DFH of the feature's registers. 176 + 177 + - Offset 0x20 178 + 179 + * Reg Size - Size of feature's register set in bytes. 180 + * Params - Set if DFH has a list of parameter blocks. 181 + * Group - Id of group if feature is part of a group. 182 + * Instance - Id of feature instance within a group. 183 + 184 + - Offset 0x28 if feature has parameters 185 + 186 + * Next - Offset to the next parameter block in 8 byte words. If EOP set, 187 + size in 8 byte words of last parameter. 188 + * Param Version - Version of Param ID. 189 + * Param ID - ID of parameter. 190 + 191 + - Offset 0x30 192 + 193 + * Parameter Data - Parameter data whose size and format is defined by 194 + version and ID of the parameter. 195 + 196 + 78 197 FIU - FME (FPGA Management Engine) 79 198 ================================== 80 199 The FPGA Management Engine performs reconfiguration and other infrastructure
+7
MAINTAINERS
··· 13703 13703 S: Maintained 13704 13704 F: drivers/i2c/busses/i2c-mchp-pci1xxxx.c 13705 13705 13706 + MICROCHIP PCIe UART DRIVER 13707 + M: Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com> 13708 + M: Tharun Kumar P <tharunkumar.pasumarthi@microchip.com> 13709 + L: linux-serial@vger.kernel.org 13710 + S: Maintained 13711 + F: drivers/tty/serial/8250/8250_pci1xxxx.c 13712 + 13706 13713 MICROCHIP PWM DRIVER 13707 13714 M: Claudiu Beznea <claudiu.beznea@microchip.com> 13708 13715 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+30
arch/arm/include/asm/semihost.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2012 ARM Ltd. 4 + * Author: Marc Zyngier <marc.zyngier@arm.com> 5 + * 6 + * Adapted for ARM and earlycon: 7 + * Copyright (C) 2014 Linaro Ltd. 8 + * Author: Rob Herring <robh@kernel.org> 9 + */ 10 + 11 + #ifndef _ARM_SEMIHOST_H_ 12 + #define _ARM_SEMIHOST_H_ 13 + 14 + #ifdef CONFIG_THUMB2_KERNEL 15 + #define SEMIHOST_SWI "0xab" 16 + #else 17 + #define SEMIHOST_SWI "0x123456" 18 + #endif 19 + 20 + struct uart_port; 21 + 22 + static inline void smh_putc(struct uart_port *port, unsigned char c) 23 + { 24 + asm volatile("mov r1, %0\n" 25 + "mov r0, #3\n" 26 + "svc " SEMIHOST_SWI "\n" 27 + : : "r" (&c) : "r0", "r1", "memory"); 28 + } 29 + 30 + #endif /* _ARM_SEMIHOST_H_ */
+24
arch/arm64/include/asm/semihost.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2012 ARM Ltd. 4 + * Author: Marc Zyngier <marc.zyngier@arm.com> 5 + * 6 + * Adapted for ARM and earlycon: 7 + * Copyright (C) 2014 Linaro Ltd. 8 + * Author: Rob Herring <robh@kernel.org> 9 + */ 10 + 11 + #ifndef _ARM64_SEMIHOST_H_ 12 + #define _ARM64_SEMIHOST_H_ 13 + 14 + struct uart_port; 15 + 16 + static inline void smh_putc(struct uart_port *port, unsigned char c) 17 + { 18 + asm volatile("mov x1, %0\n" 19 + "mov x0, #3\n" 20 + "hlt 0xf000\n" 21 + : : "r" (&c) : "x0", "x1", "memory"); 22 + } 23 + 24 + #endif /* _ARM64_SEMIHOST_H_ */
+26
arch/riscv/include/asm/semihost.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2022 tinylab.org 4 + * Author: Bin Meng <bmeng@tinylab.org> 5 + */ 6 + 7 + #ifndef _RISCV_SEMIHOST_H_ 8 + #define _RISCV_SEMIHOST_H_ 9 + 10 + struct uart_port; 11 + 12 + static inline void smh_putc(struct uart_port *port, unsigned char c) 13 + { 14 + asm volatile("addi a1, %0, 0\n" 15 + "addi a0, zero, 3\n" 16 + ".balign 16\n" 17 + ".option push\n" 18 + ".option norvc\n" 19 + "slli zero, zero, 0x1f\n" 20 + "ebreak\n" 21 + "srai zero, zero, 0x7\n" 22 + ".option pop\n" 23 + : : "r" (&c) : "a0", "a1", "memory"); 24 + } 25 + 26 + #endif /* _RISCV_SEMIHOST_H_ */
+194 -51
drivers/fpga/dfl.c
··· 13 13 #include <linux/dfl.h> 14 14 #include <linux/fpga-dfl.h> 15 15 #include <linux/module.h> 16 + #include <linux/overflow.h> 16 17 #include <linux/uaccess.h> 17 18 18 19 #include "dfl.h" ··· 343 342 if (ddev->mmio_res.parent) 344 343 release_resource(&ddev->mmio_res); 345 344 345 + kfree(ddev->params); 346 + 346 347 ida_free(&dfl_device_ida, ddev->id); 347 348 kfree(ddev->irqs); 348 349 kfree(ddev); ··· 383 380 ddev->type = feature_dev_id_type(pdev); 384 381 ddev->feature_id = feature->id; 385 382 ddev->revision = feature->revision; 383 + ddev->dfh_version = feature->dfh_version; 386 384 ddev->cdev = pdata->dfl_cdev; 385 + if (feature->param_size) { 386 + ddev->params = kmemdup(feature->params, feature->param_size, GFP_KERNEL); 387 + if (!ddev->params) { 388 + ret = -ENOMEM; 389 + goto put_dev; 390 + } 391 + ddev->param_size = feature->param_size; 392 + } 387 393 388 394 /* add mmio resource */ 389 395 parent_res = &pdev->resource[feature->resource_index]; ··· 720 708 * struct dfl_feature_info - sub feature info collected during feature dev build 721 709 * 722 710 * @fid: id of this sub feature. 711 + * @revision: revision of this sub feature 712 + * @dfh_version: version of Device Feature Header (DFH) 723 713 * @mmio_res: mmio resource of this sub feature. 724 714 * @ioaddr: mapped base address of mmio resource. 725 715 * @node: node in sub_features linked list. 726 716 * @irq_base: start of irq index in this sub feature. 727 717 * @nr_irqs: number of irqs of this sub feature. 718 + * @param_size: size DFH parameters. 719 + * @params: DFH parameter data. 728 720 */ 729 721 struct dfl_feature_info { 730 722 u16 fid; 731 723 u8 revision; 724 + u8 dfh_version; 732 725 struct resource mmio_res; 733 726 void __iomem *ioaddr; 734 727 struct list_head node; 735 728 unsigned int irq_base; 736 729 unsigned int nr_irqs; 730 + unsigned int param_size; 731 + u64 params[]; 737 732 }; 738 733 739 734 static void dfl_fpga_cdev_add_port_dev(struct dfl_fpga_cdev *cdev, ··· 816 797 feature->dev = fdev; 817 798 feature->id = finfo->fid; 818 799 feature->revision = finfo->revision; 800 + feature->dfh_version = finfo->dfh_version; 819 801 802 + if (finfo->param_size) { 803 + feature->params = devm_kmemdup(binfo->dev, 804 + finfo->params, finfo->param_size, 805 + GFP_KERNEL); 806 + if (!feature->params) 807 + return -ENOMEM; 808 + 809 + feature->param_size = finfo->param_size; 810 + } 820 811 /* 821 812 * the FIU header feature has some fundamental functions (sriov 822 813 * set, port enable/disable) needed for the dfl bus device and ··· 963 934 return 0; 964 935 } 965 936 937 + static u64 *find_param(u64 *params, resource_size_t max, int param_id) 938 + { 939 + u64 *end = params + max / sizeof(u64); 940 + u64 v, next; 941 + 942 + while (params < end) { 943 + v = *params; 944 + if (param_id == FIELD_GET(DFHv1_PARAM_HDR_ID, v)) 945 + return params; 946 + 947 + if (FIELD_GET(DFHv1_PARAM_HDR_NEXT_EOP, v)) 948 + break; 949 + 950 + next = FIELD_GET(DFHv1_PARAM_HDR_NEXT_OFFSET, v); 951 + params += next; 952 + } 953 + 954 + return NULL; 955 + } 956 + 957 + /** 958 + * dfh_find_param() - find parameter block for the given parameter id 959 + * @dfl_dev: dfl device 960 + * @param_id: id of dfl parameter 961 + * @psize: destination to store size of parameter data in bytes 962 + * 963 + * Return: pointer to start of parameter data, PTR_ERR otherwise. 964 + */ 965 + void *dfh_find_param(struct dfl_device *dfl_dev, int param_id, size_t *psize) 966 + { 967 + u64 *phdr = find_param(dfl_dev->params, dfl_dev->param_size, param_id); 968 + 969 + if (!phdr) 970 + return ERR_PTR(-ENOENT); 971 + 972 + if (psize) 973 + *psize = (FIELD_GET(DFHv1_PARAM_HDR_NEXT_OFFSET, *phdr) - 1) * sizeof(u64); 974 + 975 + return phdr + 1; 976 + } 977 + EXPORT_SYMBOL_GPL(dfh_find_param); 978 + 966 979 static int parse_feature_irqs(struct build_feature_devs_info *binfo, 967 - resource_size_t ofst, u16 fid, 968 - unsigned int *irq_base, unsigned int *nr_irqs) 980 + resource_size_t ofst, struct dfl_feature_info *finfo) 969 981 { 970 982 void __iomem *base = binfo->ioaddr + ofst; 971 983 unsigned int i, ibase, inr = 0; 984 + void *params = finfo->params; 972 985 enum dfl_id_type type; 986 + u16 fid = finfo->fid; 973 987 int virq; 988 + u64 *p; 974 989 u64 v; 975 990 976 - type = feature_dev_id_type(binfo->feature_dev); 991 + switch (finfo->dfh_version) { 992 + case 0: 993 + /* 994 + * DFHv0 only provides MMIO resource information for each feature 995 + * in the DFL header. There is no generic interrupt information. 996 + * Instead, features with interrupt functionality provide 997 + * the information in feature specific registers. 998 + */ 999 + type = feature_dev_id_type(binfo->feature_dev); 1000 + if (type == PORT_ID) { 1001 + switch (fid) { 1002 + case PORT_FEATURE_ID_UINT: 1003 + v = readq(base + PORT_UINT_CAP); 1004 + ibase = FIELD_GET(PORT_UINT_CAP_FST_VECT, v); 1005 + inr = FIELD_GET(PORT_UINT_CAP_INT_NUM, v); 1006 + break; 1007 + case PORT_FEATURE_ID_ERROR: 1008 + v = readq(base + PORT_ERROR_CAP); 1009 + ibase = FIELD_GET(PORT_ERROR_CAP_INT_VECT, v); 1010 + inr = FIELD_GET(PORT_ERROR_CAP_SUPP_INT, v); 1011 + break; 1012 + } 1013 + } else if (type == FME_ID) { 1014 + switch (fid) { 1015 + case FME_FEATURE_ID_GLOBAL_ERR: 1016 + v = readq(base + FME_ERROR_CAP); 1017 + ibase = FIELD_GET(FME_ERROR_CAP_INT_VECT, v); 1018 + inr = FIELD_GET(FME_ERROR_CAP_SUPP_INT, v); 1019 + break; 1020 + } 1021 + } 1022 + break; 977 1023 978 - /* 979 - * Ideally DFL framework should only read info from DFL header, but 980 - * current version DFL only provides mmio resources information for 981 - * each feature in DFL Header, no field for interrupt resources. 982 - * Interrupt resource information is provided by specific mmio 983 - * registers of each private feature which supports interrupt. So in 984 - * order to parse and assign irq resources, DFL framework has to look 985 - * into specific capability registers of these private features. 986 - * 987 - * Once future DFL version supports generic interrupt resource 988 - * information in common DFL headers, the generic interrupt parsing 989 - * code will be added. But in order to be compatible to old version 990 - * DFL, the driver may still fall back to these quirks. 991 - */ 992 - if (type == PORT_ID) { 993 - switch (fid) { 994 - case PORT_FEATURE_ID_UINT: 995 - v = readq(base + PORT_UINT_CAP); 996 - ibase = FIELD_GET(PORT_UINT_CAP_FST_VECT, v); 997 - inr = FIELD_GET(PORT_UINT_CAP_INT_NUM, v); 1024 + case 1: 1025 + /* 1026 + * DFHv1 provides interrupt resource information in DFHv1 1027 + * parameter blocks. 1028 + */ 1029 + p = find_param(params, finfo->param_size, DFHv1_PARAM_ID_MSI_X); 1030 + if (!p) 998 1031 break; 999 - case PORT_FEATURE_ID_ERROR: 1000 - v = readq(base + PORT_ERROR_CAP); 1001 - ibase = FIELD_GET(PORT_ERROR_CAP_INT_VECT, v); 1002 - inr = FIELD_GET(PORT_ERROR_CAP_SUPP_INT, v); 1003 - break; 1004 - } 1005 - } else if (type == FME_ID) { 1006 - if (fid == FME_FEATURE_ID_GLOBAL_ERR) { 1007 - v = readq(base + FME_ERROR_CAP); 1008 - ibase = FIELD_GET(FME_ERROR_CAP_INT_VECT, v); 1009 - inr = FIELD_GET(FME_ERROR_CAP_SUPP_INT, v); 1010 - } 1032 + 1033 + p++; 1034 + ibase = FIELD_GET(DFHv1_PARAM_MSI_X_STARTV, *p); 1035 + inr = FIELD_GET(DFHv1_PARAM_MSI_X_NUMV, *p); 1036 + break; 1037 + 1038 + default: 1039 + dev_warn(binfo->dev, "unexpected DFH version %d\n", finfo->dfh_version); 1040 + break; 1011 1041 } 1012 1042 1013 1043 if (!inr) { 1014 - *irq_base = 0; 1015 - *nr_irqs = 0; 1044 + finfo->irq_base = 0; 1045 + finfo->nr_irqs = 0; 1016 1046 return 0; 1017 1047 } 1018 1048 ··· 1094 1006 } 1095 1007 } 1096 1008 1097 - *irq_base = ibase; 1098 - *nr_irqs = inr; 1009 + finfo->irq_base = ibase; 1010 + finfo->nr_irqs = inr; 1099 1011 1100 1012 return 0; 1013 + } 1014 + 1015 + static int dfh_get_param_size(void __iomem *dfh_base, resource_size_t max) 1016 + { 1017 + int size = 0; 1018 + u64 v, next; 1019 + 1020 + if (!FIELD_GET(DFHv1_CSR_SIZE_GRP_HAS_PARAMS, 1021 + readq(dfh_base + DFHv1_CSR_SIZE_GRP))) 1022 + return 0; 1023 + 1024 + while (size + DFHv1_PARAM_HDR < max) { 1025 + v = readq(dfh_base + DFHv1_PARAM_HDR + size); 1026 + 1027 + next = FIELD_GET(DFHv1_PARAM_HDR_NEXT_OFFSET, v); 1028 + if (!next) 1029 + return -EINVAL; 1030 + 1031 + size += next * sizeof(u64); 1032 + 1033 + if (FIELD_GET(DFHv1_PARAM_HDR_NEXT_EOP, v)) 1034 + return size; 1035 + } 1036 + 1037 + return -ENOENT; 1101 1038 } 1102 1039 1103 1040 /* ··· 1136 1023 create_feature_instance(struct build_feature_devs_info *binfo, 1137 1024 resource_size_t ofst, resource_size_t size, u16 fid) 1138 1025 { 1139 - unsigned int irq_base, nr_irqs; 1140 1026 struct dfl_feature_info *finfo; 1027 + resource_size_t start, end; 1028 + int dfh_psize = 0; 1141 1029 u8 revision = 0; 1030 + u64 v, addr_off; 1031 + u8 dfh_ver = 0; 1142 1032 int ret; 1143 - u64 v; 1144 1033 1145 1034 if (fid != FEATURE_ID_AFU) { 1146 1035 v = readq(binfo->ioaddr + ofst); 1147 1036 revision = FIELD_GET(DFH_REVISION, v); 1148 - 1037 + dfh_ver = FIELD_GET(DFH_VERSION, v); 1149 1038 /* read feature size and id if inputs are invalid */ 1150 1039 size = size ? size : feature_size(v); 1151 1040 fid = fid ? fid : feature_id(v); 1041 + if (dfh_ver == 1) { 1042 + dfh_psize = dfh_get_param_size(binfo->ioaddr + ofst, size); 1043 + if (dfh_psize < 0) { 1044 + dev_err(binfo->dev, 1045 + "failed to read size of DFHv1 parameters %d\n", 1046 + dfh_psize); 1047 + return dfh_psize; 1048 + } 1049 + dev_dbg(binfo->dev, "dfhv1_psize %d\n", dfh_psize); 1050 + } 1152 1051 } 1153 1052 1154 1053 if (binfo->len - ofst < size) 1155 1054 return -EINVAL; 1156 1055 1157 - ret = parse_feature_irqs(binfo, ofst, fid, &irq_base, &nr_irqs); 1158 - if (ret) 1159 - return ret; 1160 - 1161 - finfo = kzalloc(sizeof(*finfo), GFP_KERNEL); 1056 + finfo = kzalloc(struct_size(finfo, params, dfh_psize / sizeof(u64)), GFP_KERNEL); 1162 1057 if (!finfo) 1163 1058 return -ENOMEM; 1164 1059 1060 + memcpy_fromio(finfo->params, binfo->ioaddr + ofst + DFHv1_PARAM_HDR, dfh_psize); 1061 + finfo->param_size = dfh_psize; 1062 + 1165 1063 finfo->fid = fid; 1166 1064 finfo->revision = revision; 1167 - finfo->mmio_res.start = binfo->start + ofst; 1168 - finfo->mmio_res.end = finfo->mmio_res.start + size - 1; 1065 + finfo->dfh_version = dfh_ver; 1066 + if (dfh_ver == 1) { 1067 + v = readq(binfo->ioaddr + ofst + DFHv1_CSR_ADDR); 1068 + addr_off = FIELD_GET(DFHv1_CSR_ADDR_MASK, v); 1069 + if (FIELD_GET(DFHv1_CSR_ADDR_REL, v)) 1070 + start = addr_off << 1; 1071 + else 1072 + start = binfo->start + ofst + addr_off; 1073 + 1074 + v = readq(binfo->ioaddr + ofst + DFHv1_CSR_SIZE_GRP); 1075 + end = start + FIELD_GET(DFHv1_CSR_SIZE_GRP_SIZE, v) - 1; 1076 + } else { 1077 + start = binfo->start + ofst; 1078 + end = start + size - 1; 1079 + } 1169 1080 finfo->mmio_res.flags = IORESOURCE_MEM; 1170 - finfo->irq_base = irq_base; 1171 - finfo->nr_irqs = nr_irqs; 1081 + finfo->mmio_res.start = start; 1082 + finfo->mmio_res.end = end; 1083 + 1084 + ret = parse_feature_irqs(binfo, ofst, finfo); 1085 + if (ret) { 1086 + kfree(finfo); 1087 + return ret; 1088 + } 1172 1089 1173 1090 list_add_tail(&finfo->node, &binfo->sub_features); 1174 1091 binfo->feature_num++;
+43
drivers/fpga/dfl.h
··· 74 74 #define DFH_REVISION GENMASK_ULL(15, 12) /* Feature revision */ 75 75 #define DFH_NEXT_HDR_OFST GENMASK_ULL(39, 16) /* Offset to next DFH */ 76 76 #define DFH_EOL BIT_ULL(40) /* End of list */ 77 + #define DFH_VERSION GENMASK_ULL(59, 52) /* DFH version */ 77 78 #define DFH_TYPE GENMASK_ULL(63, 60) /* Feature type */ 78 79 #define DFH_TYPE_AFU 1 79 80 #define DFH_TYPE_PRIVATE 3 80 81 #define DFH_TYPE_FIU 4 82 + 83 + /* 84 + * DFHv1 Register Offset definitons 85 + * In DHFv1, DFH + GUID + CSR_START + CSR_SIZE_GROUP + PARAM_HDR + PARAM_DATA 86 + * as common header registers 87 + */ 88 + #define DFHv1_CSR_ADDR 0x18 /* CSR Register start address */ 89 + #define DFHv1_CSR_SIZE_GRP 0x20 /* Size of Reg Block and Group/tag */ 90 + #define DFHv1_PARAM_HDR 0x28 /* Optional First Param header */ 91 + 92 + /* 93 + * CSR Rel Bit, 1'b0 = relative (offset from feature DFH start), 94 + * 1'b1 = absolute (ARM or other non-PCIe use) 95 + */ 96 + #define DFHv1_CSR_ADDR_REL BIT_ULL(0) 97 + 98 + /* CSR Header Register Bit Definitions */ 99 + #define DFHv1_CSR_ADDR_MASK GENMASK_ULL(63, 1) /* 63:1 of CSR address */ 100 + 101 + /* CSR SIZE Goup Register Bit Definitions */ 102 + #define DFHv1_CSR_SIZE_GRP_INSTANCE_ID GENMASK_ULL(15, 0) /* Enumeration instantiated IP */ 103 + #define DFHv1_CSR_SIZE_GRP_GROUPING_ID GENMASK_ULL(30, 16) /* Group Features/interfaces */ 104 + #define DFHv1_CSR_SIZE_GRP_HAS_PARAMS BIT_ULL(31) /* Presence of Parameters */ 105 + #define DFHv1_CSR_SIZE_GRP_SIZE GENMASK_ULL(63, 32) /* Size of CSR Block in bytes */ 106 + 107 + /* PARAM Header Register Bit Definitions */ 108 + #define DFHv1_PARAM_HDR_ID GENMASK_ULL(15, 0) /* Id of this Param */ 109 + #define DFHv1_PARAM_HDR_VER GENMASK_ULL(31, 16) /* Version Param */ 110 + #define DFHv1_PARAM_HDR_NEXT_OFFSET GENMASK_ULL(63, 35) /* Offset of next Param */ 111 + #define DFHv1_PARAM_HDR_NEXT_EOP BIT_ULL(32) 112 + #define DFHv1_PARAM_DATA 0x08 /* Offset of Param data from Param header */ 113 + 114 + #define DFHv1_PARAM_ID_MSI_X 0x1 115 + #define DFHv1_PARAM_MSI_X_NUMV GENMASK_ULL(63, 32) 116 + #define DFHv1_PARAM_MSI_X_STARTV GENMASK_ULL(31, 0) 81 117 82 118 /* Next AFU Register Bitfield */ 83 119 #define NEXT_AFU_NEXT_DFH_OFST GENMASK_ULL(23, 0) /* Offset to next AFU */ ··· 267 231 * 268 232 * @dev: ptr to pdev of the feature device which has the sub feature. 269 233 * @id: sub feature id. 234 + * @revision: revisition of the instance of a feature. 270 235 * @resource_index: each sub feature has one mmio resource for its registers. 271 236 * this index is used to find its mmio resource from the 272 237 * feature dev (platform device)'s resources. ··· 277 240 * @ops: ops of this sub feature. 278 241 * @ddev: ptr to the dfl device of this sub feature. 279 242 * @priv: priv data of this feature. 243 + * @dfh_version: version of the DFH 244 + * @param_size: size of dfh parameters 245 + * @params: point to memory copy of dfh parameters 280 246 */ 281 247 struct dfl_feature { 282 248 struct platform_device *dev; ··· 292 252 const struct dfl_feature_ops *ops; 293 253 struct dfl_device *ddev; 294 254 void *priv; 255 + u8 dfh_version; 256 + unsigned int param_size; 257 + void *params; 295 258 }; 296 259 297 260 #define FEATURE_DEV_ID_UNUSED (-1)
+1 -1
drivers/i2c/busses/i2c-qcom-geni.c
··· 14 14 #include <linux/of.h> 15 15 #include <linux/platform_device.h> 16 16 #include <linux/pm_runtime.h> 17 - #include <linux/qcom-geni-se.h> 17 + #include <linux/soc/qcom/geni-se.h> 18 18 #include <linux/spinlock.h> 19 19 20 20 #define SE_I2C_TX_TRANS_LEN 0x26c
+2 -2
drivers/ipack/devices/ipoctal.c
··· 647 647 tty_port_hangup(&channel->tty_port); 648 648 649 649 ipoctal_reset_channel(channel); 650 - tty_port_set_initialized(&channel->tty_port, 0); 650 + tty_port_set_initialized(&channel->tty_port, false); 651 651 wake_up_interruptible(&channel->tty_port.open_wait); 652 652 } 653 653 ··· 659 659 return; 660 660 661 661 ipoctal_reset_channel(channel); 662 - tty_port_set_initialized(&channel->tty_port, 0); 662 + tty_port_set_initialized(&channel->tty_port, false); 663 663 } 664 664 665 665 static void ipoctal_cleanup(struct tty_struct *tty)
+6 -7
drivers/mmc/core/sdio_uart.c
··· 526 526 port->in_sdio_uart_irq = NULL; 527 527 } 528 528 529 - static int uart_carrier_raised(struct tty_port *tport) 529 + static bool uart_carrier_raised(struct tty_port *tport) 530 530 { 531 531 struct sdio_uart_port *port = 532 532 container_of(tport, struct sdio_uart_port, port); ··· 535 535 return 1; 536 536 ret = sdio_uart_get_mctrl(port); 537 537 sdio_uart_release_func(port); 538 - if (ret & TIOCM_CAR) 539 - return 1; 540 - return 0; 538 + 539 + return ret & TIOCM_CAR; 541 540 } 542 541 543 542 /** 544 543 * uart_dtr_rts - port helper to set uart signals 545 544 * @tport: tty port to be updated 546 - * @onoff: set to turn on DTR/RTS 545 + * @active: set to turn on DTR/RTS 547 546 * 548 547 * Called by the tty port helpers when the modem signals need to be 549 548 * adjusted during an open, close and hangup. 550 549 */ 551 550 552 - static void uart_dtr_rts(struct tty_port *tport, int onoff) 551 + static void uart_dtr_rts(struct tty_port *tport, bool active) 553 552 { 554 553 struct sdio_uart_port *port = 555 554 container_of(tport, struct sdio_uart_port, port); 556 555 int ret = sdio_uart_claim_func(port); 557 556 if (ret) 558 557 return; 559 - if (onoff == 0) 558 + if (!active) 560 559 sdio_uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 561 560 else 562 561 sdio_uart_set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
+3 -3
drivers/pps/clients/pps-ldisc.c
··· 13 13 #include <linux/pps_kernel.h> 14 14 #include <linux/bug.h> 15 15 16 - static void pps_tty_dcd_change(struct tty_struct *tty, unsigned int status) 16 + static void pps_tty_dcd_change(struct tty_struct *tty, bool active) 17 17 { 18 18 struct pps_device *pps; 19 19 struct pps_event_time ts; ··· 29 29 return; 30 30 31 31 /* Now do the PPS event report */ 32 - pps_event(pps, &ts, status ? PPS_CAPTUREASSERT : 32 + pps_event(pps, &ts, active ? PPS_CAPTUREASSERT : 33 33 PPS_CAPTURECLEAR, NULL); 34 34 35 35 dev_dbg(pps->dev, "PPS %s at %lu\n", 36 - status ? "assert" : "clear", jiffies); 36 + active ? "assert" : "clear", jiffies); 37 37 } 38 38 39 39 static int (*alias_n_tty_open)(struct tty_struct *tty);
+2 -2
drivers/s390/char/con3215.c
··· 629 629 if (tty_port_initialized(&raw->port)) 630 630 return 0; 631 631 raw->line_pos = 0; 632 - tty_port_set_initialized(&raw->port, 1); 632 + tty_port_set_initialized(&raw->port, true); 633 633 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); 634 634 raw3215_try_io(raw); 635 635 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); ··· 659 659 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); 660 660 remove_wait_queue(&raw->empty_wait, &wait); 661 661 set_current_state(TASK_RUNNING); 662 - tty_port_set_initialized(&raw->port, 1); 662 + tty_port_set_initialized(&raw->port, true); 663 663 } 664 664 spin_unlock_irqrestore(get_ccwdev_lock(raw->cdev), flags); 665 665 }
+1 -1
drivers/soc/qcom/qcom-geni-se.c
··· 14 14 #include <linux/of_platform.h> 15 15 #include <linux/pinctrl/consumer.h> 16 16 #include <linux/platform_device.h> 17 - #include <linux/qcom-geni-se.h> 17 + #include <linux/soc/qcom/geni-se.h> 18 18 19 19 /** 20 20 * DOC: Overview
+1 -1
drivers/spi/spi-geni-qcom.c
··· 12 12 #include <linux/platform_device.h> 13 13 #include <linux/pm_opp.h> 14 14 #include <linux/pm_runtime.h> 15 - #include <linux/qcom-geni-se.h> 15 + #include <linux/soc/qcom/geni-se.h> 16 16 #include <linux/spi/spi.h> 17 17 #include <linux/spinlock.h> 18 18
+2 -2
drivers/staging/greybus/uart.c
··· 701 701 return -ENOIOCTLCMD; 702 702 } 703 703 704 - static void gb_tty_dtr_rts(struct tty_port *port, int on) 704 + static void gb_tty_dtr_rts(struct tty_port *port, bool active) 705 705 { 706 706 struct gb_tty *gb_tty; 707 707 u8 newctrl; ··· 709 709 gb_tty = container_of(port, struct gb_tty, port); 710 710 newctrl = gb_tty->ctrlout; 711 711 712 - if (on) 712 + if (active) 713 713 newctrl |= (GB_UART_CTRL_DTR | GB_UART_CTRL_RTS); 714 714 else 715 715 newctrl &= ~(GB_UART_CTRL_DTR | GB_UART_CTRL_RTS);
+6 -6
drivers/tty/amiserial.c
··· 502 502 */ 503 503 change_speed(tty, info, NULL); 504 504 505 - tty_port_set_initialized(port, 1); 505 + tty_port_set_initialized(port, true); 506 506 local_irq_restore(flags); 507 507 return 0; 508 508 ··· 556 556 557 557 set_bit(TTY_IO_ERROR, &tty->flags); 558 558 559 - tty_port_set_initialized(&info->tport, 0); 559 + tty_port_set_initialized(&info->tport, false); 560 560 local_irq_restore(flags); 561 561 } 562 562 ··· 1329 1329 rs_flush_buffer(tty); 1330 1330 shutdown(tty, info); 1331 1331 info->tport.count = 0; 1332 - tty_port_set_active(&info->tport, 0); 1332 + tty_port_set_active(&info->tport, false); 1333 1333 info->tport.tty = NULL; 1334 1334 wake_up_interruptible(&info->tport.open_wait); 1335 1335 } ··· 1454 1454 .proc_show = rs_proc_show, 1455 1455 }; 1456 1456 1457 - static int amiga_carrier_raised(struct tty_port *port) 1457 + static bool amiga_carrier_raised(struct tty_port *port) 1458 1458 { 1459 1459 return !(ciab.pra & SER_DCD); 1460 1460 } 1461 1461 1462 - static void amiga_dtr_rts(struct tty_port *port, int raise) 1462 + static void amiga_dtr_rts(struct tty_port *port, bool active) 1463 1463 { 1464 1464 struct serial_state *info = container_of(port, struct serial_state, 1465 1465 tport); 1466 1466 unsigned long flags; 1467 1467 1468 - if (raise) 1468 + if (active) 1469 1469 info->MCR |= SER_DTR|SER_RTS; 1470 1470 else 1471 1471 info->MCR &= ~(SER_DTR|SER_RTS);
+2 -2
drivers/tty/hvc/hvc_console.c
··· 376 376 /* We are ready... raise DTR/RTS */ 377 377 if (C_BAUD(tty)) 378 378 if (hp->ops->dtr_rts) 379 - hp->ops->dtr_rts(hp, 1); 379 + hp->ops->dtr_rts(hp, true); 380 380 tty_port_set_initialized(&hp->port, true); 381 381 } 382 382 ··· 406 406 407 407 if (C_HUPCL(tty)) 408 408 if (hp->ops->dtr_rts) 409 - hp->ops->dtr_rts(hp, 0); 409 + hp->ops->dtr_rts(hp, false); 410 410 411 411 if (hp->ops->notifier_del) 412 412 hp->ops->notifier_del(hp, hp->data);
+1 -1
drivers/tty/hvc/hvc_console.h
··· 66 66 int (*tiocmset)(struct hvc_struct *hp, unsigned int set, unsigned int clear); 67 67 68 68 /* Callbacks to handle tty ports */ 69 - void (*dtr_rts)(struct hvc_struct *hp, int raise); 69 + void (*dtr_rts)(struct hvc_struct *hp, bool active); 70 70 }; 71 71 72 72 /* Register a vterm and a slot index for use as a console (console_init) */
+3 -3
drivers/tty/hvc/hvc_iucv.c
··· 658 658 /** 659 659 * hvc_iucv_dtr_rts() - HVC notifier for handling DTR/RTS 660 660 * @hp: Pointer the HVC device (struct hvc_struct) 661 - * @raise: Non-zero to raise or zero to lower DTR/RTS lines 661 + * @active: True to raise or false to lower DTR/RTS lines 662 662 * 663 663 * This routine notifies the HVC back-end to raise or lower DTR/RTS 664 664 * lines. Raising DTR/RTS is ignored. Lowering DTR/RTS indicates to 665 665 * drop the IUCV connection (similar to hang up the modem). 666 666 */ 667 - static void hvc_iucv_dtr_rts(struct hvc_struct *hp, int raise) 667 + static void hvc_iucv_dtr_rts(struct hvc_struct *hp, bool active) 668 668 { 669 669 struct hvc_iucv_private *priv; 670 670 struct iucv_path *path; ··· 672 672 /* Raising the DTR/RTS is ignored as IUCV connections can be 673 673 * established at any times. 674 674 */ 675 - if (raise) 675 + if (active) 676 676 return; 677 677 678 678 priv = hvc_iucv_get_private(hp->vtermno);
+34 -57
drivers/tty/hvc/hvcs.c
··· 52 52 53 53 #include <linux/device.h> 54 54 #include <linux/init.h> 55 + #include <linux/completion.h> 55 56 #include <linux/interrupt.h> 56 57 #include <linux/kernel.h> 57 58 #include <linux/kref.h> ··· 286 285 char p_location_code[HVCS_CLC_LENGTH + 1]; /* CLC + Null Term */ 287 286 struct list_head next; /* list management */ 288 287 struct vio_dev *vdev; 288 + struct completion *destroyed; 289 289 }; 290 290 291 291 static LIST_HEAD(hvcs_structs); ··· 434 432 435 433 static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL); 436 434 437 - static struct attribute *hvcs_attrs[] = { 435 + static struct attribute *hvcs_dev_attrs[] = { 438 436 &dev_attr_partner_vtys.attr, 439 437 &dev_attr_partner_clcs.attr, 440 438 &dev_attr_current_vty.attr, ··· 443 441 NULL, 444 442 }; 445 443 446 - static struct attribute_group hvcs_attr_group = { 447 - .attrs = hvcs_attrs, 448 - }; 444 + ATTRIBUTE_GROUPS(hvcs_dev); 449 445 450 446 static ssize_t rescan_show(struct device_driver *ddp, char *buf) 451 447 { ··· 467 467 } 468 468 469 469 static DRIVER_ATTR_RW(rescan); 470 + 471 + static struct attribute *hvcs_attrs[] = { 472 + &driver_attr_rescan.attr, 473 + NULL, 474 + }; 475 + 476 + ATTRIBUTE_GROUPS(hvcs); 470 477 471 478 static void hvcs_kick(void) 472 479 { ··· 665 658 { 666 659 struct hvcs_struct *hvcsd = container_of(p, struct hvcs_struct, port); 667 660 struct vio_dev *vdev; 661 + struct completion *comp; 668 662 unsigned long flags; 669 663 670 664 spin_lock(&hvcs_structs_lock); 671 665 spin_lock_irqsave(&hvcsd->lock, flags); 672 666 667 + comp = hvcsd->destroyed; 673 668 /* the list_del poisons the pointers */ 674 669 list_del(&(hvcsd->next)); 675 670 ··· 691 682 692 683 hvcsd->p_unit_address = 0; 693 684 hvcsd->p_partition_ID = 0; 685 + hvcsd->destroyed = NULL; 694 686 hvcs_return_index(hvcsd->index); 695 687 memset(&hvcsd->p_location_code[0], 0x00, HVCS_CLC_LENGTH + 1); 696 688 697 689 spin_unlock_irqrestore(&hvcsd->lock, flags); 698 690 spin_unlock(&hvcs_structs_lock); 699 691 700 - sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group); 701 - 702 692 kfree(hvcsd); 693 + if (comp) 694 + complete(comp); 703 695 } 704 696 705 697 static const struct tty_port_operations hvcs_port_ops = { ··· 731 721 { 732 722 struct hvcs_struct *hvcsd; 733 723 int index, rc; 734 - int retval; 735 724 736 725 if (!dev || !id) { 737 726 printk(KERN_ERR "HVCS: probed with invalid parameter.\n"); ··· 787 778 list_add_tail(&(hvcsd->next), &hvcs_structs); 788 779 spin_unlock(&hvcs_structs_lock); 789 780 790 - retval = sysfs_create_group(&dev->dev.kobj, &hvcs_attr_group); 791 - if (retval) { 792 - printk(KERN_ERR "HVCS: Can't create sysfs attrs for vty-server@%X\n", 793 - hvcsd->vdev->unit_address); 794 - return retval; 795 - } 796 - 797 781 printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address); 798 782 799 783 /* ··· 799 797 static void hvcs_remove(struct vio_dev *dev) 800 798 { 801 799 struct hvcs_struct *hvcsd = dev_get_drvdata(&dev->dev); 800 + DECLARE_COMPLETION_ONSTACK(comp); 802 801 unsigned long flags; 803 802 struct tty_struct *tty; 804 803 ··· 807 804 808 805 spin_lock_irqsave(&hvcsd->lock, flags); 809 806 810 - tty = hvcsd->port.tty; 807 + hvcsd->destroyed = &comp; 808 + tty = tty_port_tty_get(&hvcsd->port); 811 809 812 810 spin_unlock_irqrestore(&hvcsd->lock, flags); 813 811 814 812 /* 815 - * Let the last holder of this object cause it to be removed, which 816 - * would probably be tty_hangup below. 817 - */ 818 - tty_port_put(&hvcsd->port); 819 - 820 - /* 821 - * The hangup is a scheduled function which will auto chain call 822 - * hvcs_hangup. The tty should always be valid at this time unless a 813 + * The tty should always be valid at this time unless a 823 814 * simultaneous tty close already cleaned up the hvcs_struct. 824 815 */ 825 - if (tty) 826 - tty_hangup(tty); 816 + if (tty) { 817 + tty_vhangup(tty); 818 + tty_kref_put(tty); 819 + } 827 820 821 + tty_port_put(&hvcsd->port); 822 + wait_for_completion(&comp); 828 823 printk(KERN_INFO "HVCS: vty-server@%X removed from the" 829 824 " vio bus.\n", dev->unit_address); 830 825 }; ··· 832 831 .probe = hvcs_probe, 833 832 .remove = hvcs_remove, 834 833 .name = hvcs_driver_name, 834 + .driver = { 835 + .groups = hvcs_groups, 836 + .dev_groups = hvcs_dev_groups, 837 + }, 835 838 }; 836 839 837 840 /* Only called from hvcs_get_pi please */ ··· 1176 1171 hvcsd = tty->driver_data; 1177 1172 1178 1173 spin_lock_irqsave(&hvcsd->lock, flags); 1179 - if (--hvcsd->port.count == 0) { 1174 + if (hvcsd->port.count == 0) { 1175 + spin_unlock_irqrestore(&hvcsd->lock, flags); 1176 + return; 1177 + } else if (--hvcsd->port.count == 0) { 1180 1178 1181 1179 vio_disable_interrupts(hvcsd->vdev); 1182 1180 ··· 1223 1215 { 1224 1216 struct hvcs_struct *hvcsd = tty->driver_data; 1225 1217 unsigned long flags; 1226 - int temp_open_count; 1227 1218 int irq; 1228 1219 1229 1220 spin_lock_irqsave(&hvcsd->lock, flags); 1230 - /* Preserve this so that we know how many kref refs to put */ 1231 - temp_open_count = hvcsd->port.count; 1232 1221 1233 1222 /* 1234 1223 * Don't kref put inside the spinlock because the destruction ··· 1235 1230 vio_disable_interrupts(hvcsd->vdev); 1236 1231 1237 1232 hvcsd->todo_mask = 0; 1238 - 1239 - /* I don't think the tty needs the hvcs_struct pointer after a hangup */ 1240 - tty->driver_data = NULL; 1241 1233 hvcsd->port.tty = NULL; 1242 - 1243 1234 hvcsd->port.count = 0; 1244 1235 1245 1236 /* This will drop any buffered data on the floor which is OK in a hangup ··· 1248 1247 spin_unlock_irqrestore(&hvcsd->lock, flags); 1249 1248 1250 1249 free_irq(irq, hvcsd); 1251 - 1252 - /* 1253 - * We need to kref_put() for every open_count we have since the 1254 - * tty_hangup() function doesn't invoke a close per open connection on a 1255 - * non-console device. 1256 - */ 1257 - while(temp_open_count) { 1258 - --temp_open_count; 1259 - /* 1260 - * The final put will trigger destruction of the hvcs_struct. 1261 - * NOTE: If this hangup was signaled from user space then the 1262 - * final put will never happen. 1263 - */ 1264 - tty_port_put(&hvcsd->port); 1265 - } 1266 1250 } 1267 1251 1268 1252 /* ··· 1511 1525 1512 1526 pr_info("HVCS: Driver registered.\n"); 1513 1527 1514 - /* This needs to be done AFTER the vio_register_driver() call or else 1515 - * the kobjects won't be initialized properly. 1516 - */ 1517 - rc = driver_create_file(&(hvcs_vio_driver.driver), &driver_attr_rescan); 1518 - if (rc) 1519 - pr_warn("HVCS: Failed to create rescan file (err %d)\n", rc); 1520 - 1521 1528 return 0; 1522 1529 } 1523 1530 ··· 1534 1555 free_page((unsigned long)hvcs_pi_buff); 1535 1556 hvcs_pi_buff = NULL; 1536 1557 spin_unlock(&hvcs_pi_lock); 1537 - 1538 - driver_remove_file(&hvcs_vio_driver.driver, &driver_attr_rescan); 1539 1558 1540 1559 tty_unregister_driver(hvcs_tty_driver); 1541 1560
+42 -40
drivers/tty/moxa.c
··· 501 501 static void moxa_poll(struct timer_list *); 502 502 static void moxa_set_tty_param(struct tty_struct *, const struct ktermios *); 503 503 static void moxa_shutdown(struct tty_port *); 504 - static int moxa_carrier_raised(struct tty_port *); 505 - static void moxa_dtr_rts(struct tty_port *, int); 504 + static bool moxa_carrier_raised(struct tty_port *); 505 + static void moxa_dtr_rts(struct tty_port *, bool); 506 506 /* 507 507 * moxa board interface functions: 508 508 */ 509 509 static void MoxaPortEnable(struct moxa_port *); 510 510 static void MoxaPortDisable(struct moxa_port *); 511 511 static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t); 512 - static int MoxaPortGetLineOut(struct moxa_port *, int *, int *); 513 - static void MoxaPortLineCtrl(struct moxa_port *, int, int); 512 + static int MoxaPortGetLineOut(struct moxa_port *, bool *, bool *); 513 + static void MoxaPortLineCtrl(struct moxa_port *, bool, bool); 514 514 static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int); 515 515 static int MoxaPortLineStatus(struct moxa_port *); 516 516 static void MoxaPortFlushData(struct moxa_port *, int); ··· 1432 1432 MoxaPortFlushData(ch, 2); 1433 1433 } 1434 1434 1435 - static int moxa_carrier_raised(struct tty_port *port) 1435 + static bool moxa_carrier_raised(struct tty_port *port) 1436 1436 { 1437 1437 struct moxa_port *ch = container_of(port, struct moxa_port, port); 1438 1438 int dcd; ··· 1443 1443 return dcd; 1444 1444 } 1445 1445 1446 - static void moxa_dtr_rts(struct tty_port *port, int onoff) 1446 + static void moxa_dtr_rts(struct tty_port *port, bool active) 1447 1447 { 1448 1448 struct moxa_port *ch = container_of(port, struct moxa_port, port); 1449 - MoxaPortLineCtrl(ch, onoff, onoff); 1449 + MoxaPortLineCtrl(ch, active, active); 1450 1450 } 1451 1451 1452 1452 ··· 1481 1481 if (!tty_port_initialized(&ch->port)) { 1482 1482 ch->statusflags = 0; 1483 1483 moxa_set_tty_param(tty, &tty->termios); 1484 - MoxaPortLineCtrl(ch, 1, 1); 1484 + MoxaPortLineCtrl(ch, true, true); 1485 1485 MoxaPortEnable(ch); 1486 1486 MoxaSetFifo(ch, ch->type == PORT_16550A); 1487 - tty_port_set_initialized(&ch->port, 1); 1487 + tty_port_set_initialized(&ch->port, true); 1488 1488 } 1489 1489 mutex_unlock(&ch->port.mutex); 1490 1490 mutex_unlock(&moxa_openlock); ··· 1557 1557 static int moxa_tiocmget(struct tty_struct *tty) 1558 1558 { 1559 1559 struct moxa_port *ch = tty->driver_data; 1560 - int flag = 0, dtr, rts; 1560 + bool dtr_active, rts_active; 1561 + int flag = 0; 1562 + int status; 1561 1563 1562 - MoxaPortGetLineOut(ch, &dtr, &rts); 1563 - if (dtr) 1564 + MoxaPortGetLineOut(ch, &dtr_active, &rts_active); 1565 + if (dtr_active) 1564 1566 flag |= TIOCM_DTR; 1565 - if (rts) 1567 + if (rts_active) 1566 1568 flag |= TIOCM_RTS; 1567 - dtr = MoxaPortLineStatus(ch); 1568 - if (dtr & 1) 1569 + status = MoxaPortLineStatus(ch); 1570 + if (status & 1) 1569 1571 flag |= TIOCM_CTS; 1570 - if (dtr & 2) 1572 + if (status & 2) 1571 1573 flag |= TIOCM_DSR; 1572 - if (dtr & 4) 1574 + if (status & 4) 1573 1575 flag |= TIOCM_CD; 1574 1576 return flag; 1575 1577 } ··· 1579 1577 static int moxa_tiocmset(struct tty_struct *tty, 1580 1578 unsigned int set, unsigned int clear) 1581 1579 { 1580 + bool dtr_active, rts_active; 1582 1581 struct moxa_port *ch; 1583 - int dtr, rts; 1584 1582 1585 1583 mutex_lock(&moxa_openlock); 1586 1584 ch = tty->driver_data; ··· 1589 1587 return -EINVAL; 1590 1588 } 1591 1589 1592 - MoxaPortGetLineOut(ch, &dtr, &rts); 1590 + MoxaPortGetLineOut(ch, &dtr_active, &rts_active); 1593 1591 if (set & TIOCM_RTS) 1594 - rts = 1; 1592 + rts_active = true; 1595 1593 if (set & TIOCM_DTR) 1596 - dtr = 1; 1594 + dtr_active = true; 1597 1595 if (clear & TIOCM_RTS) 1598 - rts = 0; 1596 + rts_active = false; 1599 1597 if (clear & TIOCM_DTR) 1600 - dtr = 0; 1601 - MoxaPortLineCtrl(ch, dtr, rts); 1598 + dtr_active = false; 1599 + MoxaPortLineCtrl(ch, dtr_active, rts_active); 1602 1600 mutex_unlock(&moxa_openlock); 1603 1601 return 0; 1604 1602 } ··· 1666 1664 u16 __iomem *ip) 1667 1665 { 1668 1666 struct tty_struct *tty = tty_port_tty_get(&p->port); 1667 + bool inited = tty_port_initialized(&p->port); 1669 1668 void __iomem *ofsAddr; 1670 - unsigned int inited = tty_port_initialized(&p->port); 1671 1669 u16 intr; 1672 1670 1673 1671 if (tty) { ··· 1879 1877 * 1880 1878 * Function 13: Get the DTR/RTS state of this port. 1881 1879 * Syntax: 1882 - * int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState); 1880 + * int MoxaPortGetLineOut(int port, bool *dtrState, bool *rtsState); 1883 1881 * int port : port number (0 - 127) 1884 - * int * dtrState : pointer to INT to receive the current DTR 1882 + * bool * dtr_active : pointer to bool to receive the current DTR 1885 1883 * state. (if NULL, this function will not 1886 1884 * write to this address) 1887 - * int * rtsState : pointer to INT to receive the current RTS 1885 + * bool * rts_active : pointer to bool to receive the current RTS 1888 1886 * state. (if NULL, this function will not 1889 1887 * write to this address) 1890 1888 * ··· 1894 1892 * 1895 1893 * Function 14: Setting the DTR/RTS output state of this port. 1896 1894 * Syntax: 1897 - * void MoxaPortLineCtrl(int port, int dtrState, int rtsState); 1895 + * void MoxaPortLineCtrl(int port, bool dtrState, bool rtsState); 1898 1896 * int port : port number (0 - 127) 1899 - * int dtrState : DTR output state (0: off, 1: on) 1900 - * int rtsState : RTS output state (0: off, 1: on) 1897 + * bool dtr_active : DTR output state 1898 + * bool rts_active : RTS output state 1901 1899 * 1902 1900 * 1903 1901 * Function 15: Setting the flow control of this port. ··· 2105 2103 return baud; 2106 2104 } 2107 2105 2108 - static int MoxaPortGetLineOut(struct moxa_port *port, int *dtrState, 2109 - int *rtsState) 2106 + static int MoxaPortGetLineOut(struct moxa_port *port, bool *dtr_active, 2107 + bool *rts_active) 2110 2108 { 2111 - if (dtrState) 2112 - *dtrState = !!(port->lineCtrl & DTR_ON); 2113 - if (rtsState) 2114 - *rtsState = !!(port->lineCtrl & RTS_ON); 2109 + if (dtr_active) 2110 + *dtr_active = port->lineCtrl & DTR_ON; 2111 + if (rts_active) 2112 + *rts_active = port->lineCtrl & RTS_ON; 2115 2113 2116 2114 return 0; 2117 2115 } 2118 2116 2119 - static void MoxaPortLineCtrl(struct moxa_port *port, int dtr, int rts) 2117 + static void MoxaPortLineCtrl(struct moxa_port *port, bool dtr_active, bool rts_active) 2120 2118 { 2121 2119 u8 mode = 0; 2122 2120 2123 - if (dtr) 2121 + if (dtr_active) 2124 2122 mode |= DTR_ON; 2125 - if (rts) 2123 + if (rts_active) 2126 2124 mode |= RTS_ON; 2127 2125 port->lineCtrl = mode; 2128 2126 moxafunc(port->tableAddr, FC_LineControl, mode);
+6 -5
drivers/tty/mxser.c
··· 458 458 outb(info->IER, info->ioaddr + UART_IER); 459 459 } 460 460 461 - static int mxser_carrier_raised(struct tty_port *port) 461 + static bool mxser_carrier_raised(struct tty_port *port) 462 462 { 463 463 struct mxser_port *mp = container_of(port, struct mxser_port, port); 464 - return (inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD)?1:0; 464 + 465 + return inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD; 465 466 } 466 467 467 - static void mxser_dtr_rts(struct tty_port *port, int on) 468 + static void mxser_dtr_rts(struct tty_port *port, bool active) 468 469 { 469 470 struct mxser_port *mp = container_of(port, struct mxser_port, port); 470 471 unsigned long flags; ··· 473 472 474 473 spin_lock_irqsave(&mp->slock, flags); 475 474 mcr = inb(mp->ioaddr + UART_MCR); 476 - if (on) 475 + if (active) 477 476 mcr |= UART_MCR_DTR | UART_MCR_RTS; 478 477 else 479 478 mcr &= ~(UART_MCR_DTR | UART_MCR_RTS); ··· 1064 1063 } else { 1065 1064 retval = mxser_activate(port, tty); 1066 1065 if (retval == 0) 1067 - tty_port_set_initialized(port, 1); 1066 + tty_port_set_initialized(port, true); 1068 1067 } 1069 1068 mutex_unlock(&port->mutex); 1070 1069 return retval;
+149 -11
drivers/tty/n_gsm.c
··· 318 318 struct gsm_control *pending_cmd;/* Our current pending command */ 319 319 spinlock_t control_lock; /* Protects the pending command */ 320 320 321 + /* Keep-alive */ 322 + struct timer_list ka_timer; /* Keep-alive response timer */ 323 + u8 ka_num; /* Keep-alive match pattern */ 324 + signed int ka_retries; /* Keep-alive retry counter, -1 if not yet initialized */ 325 + 321 326 /* Configuration */ 322 327 int adaption; /* 1 or 2 supported */ 323 328 u8 ftype; /* UI or UIH */ ··· 330 325 unsigned int t3; /* Power wake-up timer in seconds. */ 331 326 int n2; /* Retry count */ 332 327 u8 k; /* Window size */ 328 + u32 keep_alive; /* Control channel keep-alive in 10ms */ 333 329 334 330 /* Statistics (not currently exposed) */ 335 331 unsigned long bad_fcs; ··· 545 539 if (dlci->modem_tx & TIOCM_RI) 546 540 modembits |= MDM_IC; 547 541 if (dlci->modem_tx & TIOCM_CD || dlci->gsm->initiator) 542 + modembits |= MDM_DV; 543 + /* special mappings for passive side to operate as UE */ 544 + if (dlci->modem_tx & TIOCM_OUT1) 545 + modembits |= MDM_IC; 546 + if (dlci->modem_tx & TIOCM_OUT2) 548 547 modembits |= MDM_DV; 549 548 return modembits; 550 549 } ··· 1542 1531 if (brk & 0x01) 1543 1532 tty_insert_flip_char(&dlci->port, 0, TTY_BREAK); 1544 1533 dlci->modem_rx = mlines; 1534 + wake_up_interruptible(&dlci->gsm->event); 1545 1535 } 1546 1536 1547 1537 /** ··· 1909 1897 const u8 *data, int clen) 1910 1898 { 1911 1899 struct gsm_control *ctrl; 1900 + struct gsm_dlci *dlci; 1912 1901 unsigned long flags; 1913 1902 1914 1903 spin_lock_irqsave(&gsm->control_lock, flags); 1915 1904 1916 1905 ctrl = gsm->pending_cmd; 1906 + dlci = gsm->dlci[0]; 1917 1907 command |= 1; 1918 1908 /* Does the reply match our command */ 1919 1909 if (ctrl != NULL && (command == ctrl->cmd || command == CMD_NSC)) { ··· 1930 1916 /* Or did we receive the PN response to our PN command */ 1931 1917 } else if (command == CMD_PN) { 1932 1918 gsm_control_negotiation(gsm, 0, data, clen); 1919 + /* Or did we receive the TEST response to our TEST command */ 1920 + } else if (command == CMD_TEST && clen == 1 && *data == gsm->ka_num) { 1921 + gsm->ka_retries = -1; /* trigger new keep-alive message */ 1922 + if (dlci && !dlci->dead) 1923 + mod_timer(&gsm->ka_timer, jiffies + gsm->keep_alive * HZ / 100); 1924 + } 1925 + spin_unlock_irqrestore(&gsm->control_lock, flags); 1926 + } 1927 + 1928 + /** 1929 + * gsm_control_keep_alive - check timeout or start keep-alive 1930 + * @t: timer contained in our gsm object 1931 + * 1932 + * Called off the keep-alive timer expiry signaling that our link 1933 + * partner is not responding anymore. Link will be closed. 1934 + * This is also called to startup our timer. 1935 + */ 1936 + 1937 + static void gsm_control_keep_alive(struct timer_list *t) 1938 + { 1939 + struct gsm_mux *gsm = from_timer(gsm, t, ka_timer); 1940 + unsigned long flags; 1941 + 1942 + spin_lock_irqsave(&gsm->control_lock, flags); 1943 + if (gsm->ka_num && gsm->ka_retries == 0) { 1944 + /* Keep-alive expired -> close the link */ 1945 + if (debug & DBG_ERRORS) 1946 + pr_debug("%s keep-alive timed out\n", __func__); 1947 + spin_unlock_irqrestore(&gsm->control_lock, flags); 1948 + if (gsm->dlci[0]) 1949 + gsm_dlci_begin_close(gsm->dlci[0]); 1950 + return; 1951 + } else if (gsm->keep_alive && gsm->dlci[0] && !gsm->dlci[0]->dead) { 1952 + if (gsm->ka_retries > 0) { 1953 + /* T2 expired for keep-alive -> resend */ 1954 + gsm->ka_retries--; 1955 + } else { 1956 + /* Start keep-alive timer */ 1957 + gsm->ka_num++; 1958 + if (!gsm->ka_num) 1959 + gsm->ka_num++; 1960 + gsm->ka_retries = (signed int)gsm->n2; 1961 + } 1962 + gsm_control_command(gsm, CMD_TEST, &gsm->ka_num, 1963 + sizeof(gsm->ka_num)); 1964 + mod_timer(&gsm->ka_timer, 1965 + jiffies + gsm->t2 * HZ / 100); 1933 1966 } 1934 1967 spin_unlock_irqrestore(&gsm->control_lock, flags); 1935 1968 } ··· 2120 2059 tty_port_tty_hangup(&dlci->port, false); 2121 2060 gsm_dlci_clear_queues(dlci->gsm, dlci); 2122 2061 /* Ensure that gsmtty_open() can return. */ 2123 - tty_port_set_initialized(&dlci->port, 0); 2062 + tty_port_set_initialized(&dlci->port, false); 2124 2063 wake_up_interruptible(&dlci->port.open_wait); 2125 - } else 2064 + } else { 2065 + del_timer(&dlci->gsm->ka_timer); 2126 2066 dlci->gsm->dead = true; 2067 + } 2127 2068 /* A DLCI 0 close is a MUX termination so we need to kick that 2128 2069 back to userspace somehow */ 2129 2070 gsm_dlci_data_kick(dlci); 2130 - wake_up(&dlci->gsm->event); 2071 + wake_up_all(&dlci->gsm->event); 2131 2072 } 2132 2073 2133 2074 /** ··· 2141 2078 2142 2079 static void gsm_dlci_open(struct gsm_dlci *dlci) 2143 2080 { 2081 + struct gsm_mux *gsm = dlci->gsm; 2082 + 2144 2083 /* Note that SABM UA .. SABM UA first UA lost can mean that we go 2145 2084 open -> open */ 2146 2085 del_timer(&dlci->t1); ··· 2152 2087 if (debug & DBG_ERRORS) 2153 2088 pr_debug("DLCI %d goes open.\n", dlci->addr); 2154 2089 /* Send current modem state */ 2155 - if (dlci->addr) 2090 + if (dlci->addr) { 2156 2091 gsm_modem_update(dlci, 0); 2092 + } else { 2093 + /* Start keep-alive control */ 2094 + gsm->ka_num = 0; 2095 + gsm->ka_retries = -1; 2096 + mod_timer(&gsm->ka_timer, 2097 + jiffies + gsm->keep_alive * HZ / 100); 2098 + } 2157 2099 gsm_dlci_data_kick(dlci); 2158 2100 wake_up(&dlci->gsm->event); 2159 2101 } ··· 2339 2267 dlci->state = DLCI_CLOSING; 2340 2268 gsm_command(dlci->gsm, dlci->addr, DISC|PF); 2341 2269 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100); 2270 + wake_up_interruptible(&gsm->event); 2342 2271 } 2343 2272 2344 2273 /** ··· 2913 2840 /* Finish outstanding timers, making sure they are done */ 2914 2841 del_timer_sync(&gsm->kick_timer); 2915 2842 del_timer_sync(&gsm->t2_timer); 2843 + del_timer_sync(&gsm->ka_timer); 2916 2844 2917 2845 /* Finish writing to ldisc */ 2918 2846 flush_work(&gsm->tx_work); ··· 3061 2987 INIT_LIST_HEAD(&gsm->tx_data_list); 3062 2988 timer_setup(&gsm->kick_timer, gsm_kick_timer, 0); 3063 2989 timer_setup(&gsm->t2_timer, gsm_control_retransmit, 0); 2990 + timer_setup(&gsm->ka_timer, gsm_control_keep_alive, 0); 3064 2991 INIT_WORK(&gsm->tx_work, gsmld_write_task); 3065 2992 init_waitqueue_head(&gsm->event); 3066 2993 spin_lock_init(&gsm->control_lock); ··· 3078 3003 gsm->mru = 64; /* Default to encoding 1 so these should be 64 */ 3079 3004 gsm->mtu = 64; 3080 3005 gsm->dead = true; /* Avoid early tty opens */ 3006 + gsm->keep_alive = 0; /* Disabled */ 3081 3007 3082 3008 /* Store the instance to the mux array or abort if no space is 3083 3009 * available. ··· 3211 3135 if (gsm->initiator) 3212 3136 gsm_dlci_begin_open(gsm->dlci[0]); 3213 3137 } 3138 + return 0; 3139 + } 3140 + 3141 + static void gsm_copy_config_ext_values(struct gsm_mux *gsm, 3142 + struct gsm_config_ext *ce) 3143 + { 3144 + memset(ce, 0, sizeof(*ce)); 3145 + ce->keep_alive = gsm->keep_alive; 3146 + } 3147 + 3148 + static int gsm_config_ext(struct gsm_mux *gsm, struct gsm_config_ext *ce) 3149 + { 3150 + unsigned int i; 3151 + 3152 + /* 3153 + * Check that userspace doesn't put stuff in here to prevent breakages 3154 + * in the future. 3155 + */ 3156 + for (i = 0; i < ARRAY_SIZE(ce->reserved); i++) 3157 + if (ce->reserved[i]) 3158 + return -EINVAL; 3159 + 3160 + gsm->keep_alive = ce->keep_alive; 3214 3161 return 0; 3215 3162 } 3216 3163 ··· 3555 3456 unsigned long arg) 3556 3457 { 3557 3458 struct gsm_config c; 3459 + struct gsm_config_ext ce; 3558 3460 struct gsm_mux *gsm = tty->disc_data; 3559 3461 unsigned int base; 3560 3462 ··· 3572 3472 case GSMIOC_GETFIRST: 3573 3473 base = mux_num_to_base(gsm); 3574 3474 return put_user(base + 1, (__u32 __user *)arg); 3475 + case GSMIOC_GETCONF_EXT: 3476 + gsm_copy_config_ext_values(gsm, &ce); 3477 + if (copy_to_user((void __user *)arg, &ce, sizeof(ce))) 3478 + return -EFAULT; 3479 + return 0; 3480 + case GSMIOC_SETCONF_EXT: 3481 + if (copy_from_user(&ce, (void __user *)arg, sizeof(ce))) 3482 + return -EFAULT; 3483 + return gsm_config_ext(gsm, &ce); 3575 3484 default: 3576 3485 return n_tty_ioctl_helper(tty, cmd, arg); 3577 3486 } ··· 3879 3770 return -EPROTONOSUPPORT; 3880 3771 } 3881 3772 3882 - static int gsm_carrier_raised(struct tty_port *port) 3773 + /** 3774 + * gsm_wait_modem_change - wait for modem status line change 3775 + * @dlci: channel 3776 + * @mask: modem status line bits 3777 + * 3778 + * The function returns if: 3779 + * - any given modem status line bit changed 3780 + * - the wait event function got interrupted (e.g. by a signal) 3781 + * - the underlying DLCI was closed 3782 + * - the underlying ldisc device was removed 3783 + */ 3784 + static int gsm_wait_modem_change(struct gsm_dlci *dlci, u32 mask) 3785 + { 3786 + struct gsm_mux *gsm = dlci->gsm; 3787 + u32 old = dlci->modem_rx; 3788 + int ret; 3789 + 3790 + ret = wait_event_interruptible(gsm->event, gsm->dead || 3791 + dlci->state != DLCI_OPEN || 3792 + (old ^ dlci->modem_rx) & mask); 3793 + if (gsm->dead) 3794 + return -ENODEV; 3795 + if (dlci->state != DLCI_OPEN) 3796 + return -EL2NSYNC; 3797 + return ret; 3798 + } 3799 + 3800 + static bool gsm_carrier_raised(struct tty_port *port) 3883 3801 { 3884 3802 struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port); 3885 3803 struct gsm_mux *gsm = dlci->gsm; 3886 3804 3887 3805 /* Not yet open so no carrier info */ 3888 3806 if (dlci->state != DLCI_OPEN) 3889 - return 0; 3807 + return false; 3890 3808 if (debug & DBG_CD_ON) 3891 - return 1; 3809 + return true; 3892 3810 3893 3811 /* 3894 3812 * Basic mode with control channel in ADM mode may not respond ··· 3923 3787 */ 3924 3788 if (gsm->encoding == GSM_BASIC_OPT && 3925 3789 gsm->dlci[0]->mode == DLCI_MODE_ADM && !dlci->modem_rx) 3926 - return 1; 3790 + return true; 3927 3791 3928 3792 return dlci->modem_rx & TIOCM_CD; 3929 3793 } 3930 3794 3931 - static void gsm_dtr_rts(struct tty_port *port, int onoff) 3795 + static void gsm_dtr_rts(struct tty_port *port, bool active) 3932 3796 { 3933 3797 struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port); 3934 3798 unsigned int modem_tx = dlci->modem_tx; 3935 - if (onoff) 3799 + if (active) 3936 3800 modem_tx |= TIOCM_DTR | TIOCM_RTS; 3937 3801 else 3938 3802 modem_tx &= ~(TIOCM_DTR | TIOCM_RTS); ··· 4016 3880 dlci->modem_rx = 0; 4017 3881 /* We could in theory open and close before we wait - eg if we get 4018 3882 a DM straight back. This is ok as that will have caused a hangup */ 4019 - tty_port_set_initialized(port, 1); 3883 + tty_port_set_initialized(port, true); 4020 3884 /* Start sending off SABM messages */ 4021 3885 if (gsm->initiator) 4022 3886 gsm_dlci_begin_open(dlci); ··· 4165 4029 gsm_destroy_network(dlci); 4166 4030 mutex_unlock(&dlci->mutex); 4167 4031 return 0; 4032 + case TIOCMIWAIT: 4033 + return gsm_wait_modem_change(dlci, (u32)arg); 4168 4034 default: 4169 4035 return -ENOIOCTLCMD; 4170 4036 }
+167
drivers/tty/serial/8250/8250_dfl.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Driver for FPGA UART 4 + * 5 + * Copyright (C) 2022 Intel Corporation. 6 + * 7 + * Authors: 8 + * Ananda Ravuri <ananda.ravuri@intel.com> 9 + * Matthew Gerlach <matthew.gerlach@linux.intel.com> 10 + */ 11 + 12 + #include <linux/bitfield.h> 13 + #include <linux/device.h> 14 + #include <linux/dfl.h> 15 + #include <linux/errno.h> 16 + #include <linux/ioport.h> 17 + #include <linux/module.h> 18 + #include <linux/mod_devicetable.h> 19 + #include <linux/types.h> 20 + 21 + #include <linux/serial.h> 22 + #include <linux/serial_8250.h> 23 + 24 + #define DFHv1_PARAM_ID_CLK_FRQ 0x2 25 + #define DFHv1_PARAM_ID_FIFO_LEN 0x3 26 + 27 + #define DFHv1_PARAM_ID_REG_LAYOUT 0x4 28 + #define DFHv1_PARAM_REG_LAYOUT_WIDTH GENMASK_ULL(63, 32) 29 + #define DFHv1_PARAM_REG_LAYOUT_SHIFT GENMASK_ULL(31, 0) 30 + 31 + struct dfl_uart { 32 + int line; 33 + }; 34 + 35 + static int dfh_get_u64_param_val(struct dfl_device *dfl_dev, int param_id, u64 *pval) 36 + { 37 + size_t psize; 38 + u64 *p; 39 + 40 + p = dfh_find_param(dfl_dev, param_id, &psize); 41 + if (IS_ERR(p)) 42 + return PTR_ERR(p); 43 + 44 + if (psize != sizeof(*pval)) 45 + return -EINVAL; 46 + 47 + *pval = *p; 48 + 49 + return 0; 50 + } 51 + 52 + static int dfl_uart_get_params(struct dfl_device *dfl_dev, struct uart_8250_port *uart) 53 + { 54 + struct device *dev = &dfl_dev->dev; 55 + u64 fifo_len, clk_freq, reg_layout; 56 + u32 reg_width; 57 + int ret; 58 + 59 + ret = dfh_get_u64_param_val(dfl_dev, DFHv1_PARAM_ID_CLK_FRQ, &clk_freq); 60 + if (ret) 61 + return dev_err_probe(dev, ret, "missing CLK_FRQ param\n"); 62 + 63 + uart->port.uartclk = clk_freq; 64 + 65 + ret = dfh_get_u64_param_val(dfl_dev, DFHv1_PARAM_ID_FIFO_LEN, &fifo_len); 66 + if (ret) 67 + return dev_err_probe(dev, ret, "missing FIFO_LEN param\n"); 68 + 69 + switch (fifo_len) { 70 + case 32: 71 + uart->port.type = PORT_ALTR_16550_F32; 72 + break; 73 + 74 + case 64: 75 + uart->port.type = PORT_ALTR_16550_F64; 76 + break; 77 + 78 + case 128: 79 + uart->port.type = PORT_ALTR_16550_F128; 80 + break; 81 + 82 + default: 83 + return dev_err_probe(dev, -EINVAL, "unsupported FIFO_LEN %llu\n", fifo_len); 84 + } 85 + 86 + ret = dfh_get_u64_param_val(dfl_dev, DFHv1_PARAM_ID_REG_LAYOUT, &reg_layout); 87 + if (ret) 88 + return dev_err_probe(dev, ret, "missing REG_LAYOUT param\n"); 89 + 90 + uart->port.regshift = FIELD_GET(DFHv1_PARAM_REG_LAYOUT_SHIFT, reg_layout); 91 + reg_width = FIELD_GET(DFHv1_PARAM_REG_LAYOUT_WIDTH, reg_layout); 92 + switch (reg_width) { 93 + case 4: 94 + uart->port.iotype = UPIO_MEM32; 95 + break; 96 + 97 + case 2: 98 + uart->port.iotype = UPIO_MEM16; 99 + break; 100 + 101 + default: 102 + return dev_err_probe(dev, -EINVAL, "unsupported reg-width %u\n", reg_width); 103 + 104 + } 105 + 106 + return 0; 107 + } 108 + 109 + static int dfl_uart_probe(struct dfl_device *dfl_dev) 110 + { 111 + struct device *dev = &dfl_dev->dev; 112 + struct uart_8250_port uart = { }; 113 + struct dfl_uart *dfluart; 114 + int ret; 115 + 116 + uart.port.flags = UPF_IOREMAP; 117 + uart.port.mapbase = dfl_dev->mmio_res.start; 118 + uart.port.mapsize = resource_size(&dfl_dev->mmio_res); 119 + 120 + ret = dfl_uart_get_params(dfl_dev, &uart); 121 + if (ret < 0) 122 + return dev_err_probe(dev, ret, "failed uart feature walk\n"); 123 + 124 + if (dfl_dev->num_irqs == 1) 125 + uart.port.irq = dfl_dev->irqs[0]; 126 + 127 + dfluart = devm_kzalloc(dev, sizeof(*dfluart), GFP_KERNEL); 128 + if (!dfluart) 129 + return -ENOMEM; 130 + 131 + dfluart->line = serial8250_register_8250_port(&uart); 132 + if (dfluart->line < 0) 133 + return dev_err_probe(dev, dfluart->line, "unable to register 8250 port.\n"); 134 + 135 + dev_set_drvdata(dev, dfluart); 136 + 137 + return 0; 138 + } 139 + 140 + static void dfl_uart_remove(struct dfl_device *dfl_dev) 141 + { 142 + struct dfl_uart *dfluart = dev_get_drvdata(&dfl_dev->dev); 143 + 144 + serial8250_unregister_port(dfluart->line); 145 + } 146 + 147 + #define FME_FEATURE_ID_UART 0x24 148 + 149 + static const struct dfl_device_id dfl_uart_ids[] = { 150 + { FME_ID, FME_FEATURE_ID_UART }, 151 + { } 152 + }; 153 + MODULE_DEVICE_TABLE(dfl, dfl_uart_ids); 154 + 155 + static struct dfl_driver dfl_uart_driver = { 156 + .drv = { 157 + .name = "dfl-uart", 158 + }, 159 + .id_table = dfl_uart_ids, 160 + .probe = dfl_uart_probe, 161 + .remove = dfl_uart_remove, 162 + }; 163 + module_dfl_driver(dfl_uart_driver); 164 + 165 + MODULE_DESCRIPTION("DFL Intel UART driver"); 166 + MODULE_AUTHOR("Intel Corporation"); 167 + MODULE_LICENSE("GPL");
+2 -2
drivers/tty/serial/8250/8250_early.c
··· 136 136 unsigned char c; 137 137 unsigned int ier; 138 138 139 - serial8250_early_out(port, UART_LCR, 0x3); /* 8n1 */ 139 + serial8250_early_out(port, UART_LCR, UART_LCR_WLEN8); /* 8n1 */ 140 140 ier = serial8250_early_in(port, UART_IER); 141 141 serial8250_early_out(port, UART_IER, ier & UART_IER_UUE); /* no interrupt */ 142 142 serial8250_early_out(port, UART_FCR, 0); /* no fifo */ 143 - serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */ 143 + serial8250_early_out(port, UART_MCR, UART_MCR_DTR | UART_MCR_RTS); 144 144 145 145 if (port->uartclk) { 146 146 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
+3 -22
drivers/tty/serial/8250/8250_pci.c
··· 24 24 #include <asm/io.h> 25 25 26 26 #include "8250.h" 27 + #include "8250_pcilib.h" 27 28 28 29 /* 29 30 * init function returns: ··· 90 89 setup_port(struct serial_private *priv, struct uart_8250_port *port, 91 90 u8 bar, unsigned int offset, int regshift) 92 91 { 93 - struct pci_dev *dev = priv->dev; 94 - 95 - if (bar >= PCI_STD_NUM_BARS) 96 - return -EINVAL; 97 - 98 - if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) { 99 - if (!pcim_iomap(dev, bar, 0) && !pcim_iomap_table(dev)) 100 - return -ENOMEM; 101 - 102 - port->port.iotype = UPIO_MEM; 103 - port->port.iobase = 0; 104 - port->port.mapbase = pci_resource_start(dev, bar) + offset; 105 - port->port.membase = pcim_iomap_table(dev)[bar] + offset; 106 - port->port.regshift = regshift; 107 - } else { 108 - port->port.iotype = UPIO_PORT; 109 - port->port.iobase = pci_resource_start(dev, bar) + offset; 110 - port->port.mapbase = 0; 111 - port->port.membase = NULL; 112 - port->port.regshift = 0; 113 - } 114 - return 0; 92 + return serial8250_pci_setup_port(priv->dev, port, bar, offset, regshift); 115 93 } 116 94 117 95 /* ··· 5737 5757 MODULE_LICENSE("GPL"); 5738 5758 MODULE_DESCRIPTION("Generic 8250/16x50 PCI serial probe module"); 5739 5759 MODULE_DEVICE_TABLE(pci, serial_pci_tbl); 5760 + MODULE_IMPORT_NS(SERIAL_8250_PCI);
+494
drivers/tty/serial/8250/8250_pci1xxxx.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Probe module for 8250/16550-type MCHP PCI serial ports. 4 + * 5 + * Based on drivers/tty/serial/8250/8250_pci.c, 6 + * 7 + * Copyright (C) 2022 Microchip Technology Inc., All Rights Reserved. 8 + */ 9 + 10 + #include <linux/bitfield.h> 11 + #include <linux/bitops.h> 12 + #include <linux/io.h> 13 + #include <linux/kernel.h> 14 + #include <linux/module.h> 15 + #include <linux/pci.h> 16 + #include <linux/serial_core.h> 17 + #include <linux/slab.h> 18 + #include <linux/string.h> 19 + #include <linux/units.h> 20 + #include <linux/tty.h> 21 + 22 + #include <asm/byteorder.h> 23 + 24 + #include "8250.h" 25 + #include "8250_pcilib.h" 26 + 27 + #define PCI_DEVICE_ID_EFAR_PCI12000 0xa002 28 + #define PCI_DEVICE_ID_EFAR_PCI11010 0xa012 29 + #define PCI_DEVICE_ID_EFAR_PCI11101 0xa022 30 + #define PCI_DEVICE_ID_EFAR_PCI11400 0xa032 31 + #define PCI_DEVICE_ID_EFAR_PCI11414 0xa042 32 + 33 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_4p 0x0001 34 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p012 0x0002 35 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p013 0x0003 36 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p023 0x0004 37 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p123 0x0005 38 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p01 0x0006 39 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p02 0x0007 40 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p03 0x0008 41 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p12 0x0009 42 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p13 0x000a 43 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p23 0x000b 44 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p0 0x000c 45 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p1 0x000d 46 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p2 0x000e 47 + #define PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p3 0x000f 48 + 49 + #define PCI_SUBDEVICE_ID_EFAR_PCI12000 PCI_DEVICE_ID_EFAR_PCI12000 50 + #define PCI_SUBDEVICE_ID_EFAR_PCI11010 PCI_DEVICE_ID_EFAR_PCI11010 51 + #define PCI_SUBDEVICE_ID_EFAR_PCI11101 PCI_DEVICE_ID_EFAR_PCI11101 52 + #define PCI_SUBDEVICE_ID_EFAR_PCI11400 PCI_DEVICE_ID_EFAR_PCI11400 53 + #define PCI_SUBDEVICE_ID_EFAR_PCI11414 PCI_DEVICE_ID_EFAR_PCI11414 54 + 55 + #define UART_ACTV_REG 0x11 56 + #define UART_BLOCK_SET_ACTIVE BIT(0) 57 + 58 + #define UART_PCI_CTRL_REG 0x80 59 + #define UART_PCI_CTRL_SET_MULTIPLE_MSI BIT(4) 60 + #define UART_PCI_CTRL_D3_CLK_ENABLE BIT(0) 61 + 62 + #define ADCL_CFG_REG 0x40 63 + #define ADCL_CFG_POL_SEL BIT(2) 64 + #define ADCL_CFG_PIN_SEL BIT(1) 65 + #define ADCL_CFG_EN BIT(0) 66 + 67 + #define UART_BIT_SAMPLE_CNT 16 68 + #define BAUD_CLOCK_DIV_INT_MSK GENMASK(31, 8) 69 + #define ADCL_CFG_RTS_DELAY_MASK GENMASK(11, 8) 70 + #define UART_CLOCK_DEFAULT (62500 * HZ_PER_KHZ) 71 + 72 + #define UART_WAKE_REG 0x8C 73 + #define UART_WAKE_MASK_REG 0x90 74 + #define UART_WAKE_N_PIN BIT(2) 75 + #define UART_WAKE_NCTS BIT(1) 76 + #define UART_WAKE_INT BIT(0) 77 + #define UART_WAKE_SRCS \ 78 + (UART_WAKE_N_PIN | UART_WAKE_NCTS | UART_WAKE_INT) 79 + 80 + #define UART_BAUD_CLK_DIVISOR_REG 0x54 81 + 82 + #define UART_RESET_REG 0x94 83 + #define UART_RESET_D3_RESET_DISABLE BIT(16) 84 + 85 + #define MAX_PORTS 4 86 + #define PORT_OFFSET 0x100 87 + 88 + static const int logical_to_physical_port_idx[][MAX_PORTS] = { 89 + {0, 1, 2, 3}, /* PCI12000, PCI11010, PCI11101, PCI11400, PCI11414 */ 90 + {0, 1, 2, 3}, /* PCI4p */ 91 + {0, 1, 2, -1}, /* PCI3p012 */ 92 + {0, 1, 3, -1}, /* PCI3p013 */ 93 + {0, 2, 3, -1}, /* PCI3p023 */ 94 + {1, 2, 3, -1}, /* PCI3p123 */ 95 + {0, 1, -1, -1}, /* PCI2p01 */ 96 + {0, 2, -1, -1}, /* PCI2p02 */ 97 + {0, 3, -1, -1}, /* PCI2p03 */ 98 + {1, 2, -1, -1}, /* PCI2p12 */ 99 + {1, 3, -1, -1}, /* PCI2p13 */ 100 + {2, 3, -1, -1}, /* PCI2p23 */ 101 + {0, -1, -1, -1}, /* PCI1p0 */ 102 + {1, -1, -1, -1}, /* PCI1p1 */ 103 + {2, -1, -1, -1}, /* PCI1p2 */ 104 + {3, -1, -1, -1}, /* PCI1p3 */ 105 + }; 106 + 107 + struct pci1xxxx_8250 { 108 + unsigned int nr; 109 + void __iomem *membase; 110 + int line[]; 111 + }; 112 + 113 + static int pci1xxxx_get_num_ports(struct pci_dev *dev) 114 + { 115 + switch (dev->subsystem_device) { 116 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p0: 117 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p1: 118 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p2: 119 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p3: 120 + case PCI_SUBDEVICE_ID_EFAR_PCI12000: 121 + case PCI_SUBDEVICE_ID_EFAR_PCI11010: 122 + case PCI_SUBDEVICE_ID_EFAR_PCI11101: 123 + case PCI_SUBDEVICE_ID_EFAR_PCI11400: 124 + default: 125 + return 1; 126 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p01: 127 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p02: 128 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p03: 129 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p12: 130 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p13: 131 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_2p23: 132 + return 2; 133 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p012: 134 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p123: 135 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p013: 136 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_3p023: 137 + return 3; 138 + case PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_4p: 139 + case PCI_SUBDEVICE_ID_EFAR_PCI11414: 140 + return 4; 141 + } 142 + } 143 + 144 + static unsigned int pci1xxxx_get_divisor(struct uart_port *port, 145 + unsigned int baud, unsigned int *frac) 146 + { 147 + unsigned int quot; 148 + 149 + /* 150 + * Calculate baud rate sampling period in nanoseconds. 151 + * Fractional part x denotes x/255 parts of a nanosecond. 152 + */ 153 + quot = NSEC_PER_SEC / (baud * UART_BIT_SAMPLE_CNT); 154 + *frac = (NSEC_PER_SEC - quot * baud * UART_BIT_SAMPLE_CNT) * 155 + 255 / UART_BIT_SAMPLE_CNT / baud; 156 + 157 + return quot; 158 + } 159 + 160 + static void pci1xxxx_set_divisor(struct uart_port *port, unsigned int baud, 161 + unsigned int quot, unsigned int frac) 162 + { 163 + writel(FIELD_PREP(BAUD_CLOCK_DIV_INT_MSK, quot) | frac, 164 + port->membase + UART_BAUD_CLK_DIVISOR_REG); 165 + } 166 + 167 + static int pci1xxxx_rs485_config(struct uart_port *port, 168 + struct ktermios *termios, 169 + struct serial_rs485 *rs485) 170 + { 171 + u32 delay_in_baud_periods; 172 + u32 baud_period_in_ns; 173 + u32 mode_cfg = 0; 174 + u32 clock_div; 175 + 176 + /* 177 + * pci1xxxx's uart hardware supports only RTS delay after 178 + * Tx and in units of bit times to a maximum of 15 179 + */ 180 + if (rs485->flags & SER_RS485_ENABLED) { 181 + mode_cfg = ADCL_CFG_EN | ADCL_CFG_PIN_SEL; 182 + 183 + if (!(rs485->flags & SER_RS485_RTS_ON_SEND)) 184 + mode_cfg |= ADCL_CFG_POL_SEL; 185 + 186 + if (rs485->delay_rts_after_send) { 187 + clock_div = readl(port->membase + UART_BAUD_CLK_DIVISOR_REG); 188 + baud_period_in_ns = 189 + FIELD_GET(BAUD_CLOCK_DIV_INT_MSK, clock_div) * 190 + UART_BIT_SAMPLE_CNT; 191 + delay_in_baud_periods = 192 + rs485->delay_rts_after_send * NSEC_PER_MSEC / 193 + baud_period_in_ns; 194 + delay_in_baud_periods = 195 + min_t(u32, delay_in_baud_periods, 196 + FIELD_MAX(ADCL_CFG_RTS_DELAY_MASK)); 197 + mode_cfg |= FIELD_PREP(ADCL_CFG_RTS_DELAY_MASK, 198 + delay_in_baud_periods); 199 + rs485->delay_rts_after_send = 200 + baud_period_in_ns * delay_in_baud_periods / 201 + NSEC_PER_MSEC; 202 + } 203 + } 204 + writel(mode_cfg, port->membase + ADCL_CFG_REG); 205 + return 0; 206 + } 207 + 208 + static const struct serial_rs485 pci1xxxx_rs485_supported = { 209 + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | 210 + SER_RS485_RTS_AFTER_SEND, 211 + .delay_rts_after_send = 1, 212 + /* Delay RTS before send is not supported */ 213 + }; 214 + 215 + static bool pci1xxxx_port_suspend(int line) 216 + { 217 + struct uart_8250_port *up = serial8250_get_port(line); 218 + struct uart_port *port = &up->port; 219 + struct tty_port *tport = &port->state->port; 220 + unsigned long flags; 221 + bool ret = false; 222 + u8 wakeup_mask; 223 + 224 + mutex_lock(&tport->mutex); 225 + if (port->suspended == 0 && port->dev) { 226 + wakeup_mask = readb(up->port.membase + UART_WAKE_MASK_REG); 227 + 228 + spin_lock_irqsave(&port->lock, flags); 229 + port->mctrl &= ~TIOCM_OUT2; 230 + port->ops->set_mctrl(port, port->mctrl); 231 + spin_unlock_irqrestore(&port->lock, flags); 232 + 233 + ret = (wakeup_mask & UART_WAKE_SRCS) != UART_WAKE_SRCS; 234 + } 235 + 236 + writeb(UART_WAKE_SRCS, port->membase + UART_WAKE_REG); 237 + mutex_unlock(&tport->mutex); 238 + 239 + return ret; 240 + } 241 + 242 + static void pci1xxxx_port_resume(int line) 243 + { 244 + struct uart_8250_port *up = serial8250_get_port(line); 245 + struct uart_port *port = &up->port; 246 + struct tty_port *tport = &port->state->port; 247 + unsigned long flags; 248 + 249 + mutex_lock(&tport->mutex); 250 + writeb(UART_BLOCK_SET_ACTIVE, port->membase + UART_ACTV_REG); 251 + writeb(UART_WAKE_SRCS, port->membase + UART_WAKE_REG); 252 + 253 + if (port->suspended == 0) { 254 + spin_lock_irqsave(&port->lock, flags); 255 + port->mctrl |= TIOCM_OUT2; 256 + port->ops->set_mctrl(port, port->mctrl); 257 + spin_unlock_irqrestore(&port->lock, flags); 258 + } 259 + mutex_unlock(&tport->mutex); 260 + } 261 + 262 + static int pci1xxxx_suspend(struct device *dev) 263 + { 264 + struct pci1xxxx_8250 *priv = dev_get_drvdata(dev); 265 + struct pci_dev *pcidev = to_pci_dev(dev); 266 + bool wakeup = false; 267 + unsigned int data; 268 + void __iomem *p; 269 + int i; 270 + 271 + for (i = 0; i < priv->nr; i++) { 272 + if (priv->line[i] >= 0) { 273 + serial8250_suspend_port(priv->line[i]); 274 + wakeup |= pci1xxxx_port_suspend(priv->line[i]); 275 + } 276 + } 277 + 278 + p = pci_ioremap_bar(pcidev, 0); 279 + if (!p) { 280 + dev_err(dev, "remapping of bar 0 memory failed"); 281 + return -ENOMEM; 282 + } 283 + 284 + data = readl(p + UART_RESET_REG); 285 + writel(data | UART_RESET_D3_RESET_DISABLE, p + UART_RESET_REG); 286 + 287 + if (wakeup) 288 + writeb(UART_PCI_CTRL_D3_CLK_ENABLE, p + UART_PCI_CTRL_REG); 289 + 290 + iounmap(p); 291 + device_set_wakeup_enable(dev, true); 292 + pci_wake_from_d3(pcidev, true); 293 + 294 + return 0; 295 + } 296 + 297 + static int pci1xxxx_resume(struct device *dev) 298 + { 299 + struct pci1xxxx_8250 *priv = dev_get_drvdata(dev); 300 + struct pci_dev *pcidev = to_pci_dev(dev); 301 + unsigned int data; 302 + void __iomem *p; 303 + int i; 304 + 305 + p = pci_ioremap_bar(pcidev, 0); 306 + if (!p) { 307 + dev_err(dev, "remapping of bar 0 memory failed"); 308 + return -ENOMEM; 309 + } 310 + 311 + data = readl(p + UART_RESET_REG); 312 + writel(data & ~UART_RESET_D3_RESET_DISABLE, p + UART_RESET_REG); 313 + iounmap(p); 314 + 315 + for (i = 0; i < priv->nr; i++) { 316 + if (priv->line[i] >= 0) { 317 + pci1xxxx_port_resume(priv->line[i]); 318 + serial8250_resume_port(priv->line[i]); 319 + } 320 + } 321 + 322 + return 0; 323 + } 324 + 325 + static int pci1xxxx_setup(struct pci_dev *pdev, 326 + struct uart_8250_port *port, int port_idx) 327 + { 328 + int ret; 329 + 330 + port->port.flags |= UPF_FIXED_TYPE | UPF_SKIP_TEST; 331 + port->port.type = PORT_MCHP16550A; 332 + port->port.set_termios = serial8250_do_set_termios; 333 + port->port.get_divisor = pci1xxxx_get_divisor; 334 + port->port.set_divisor = pci1xxxx_set_divisor; 335 + port->port.rs485_config = pci1xxxx_rs485_config; 336 + port->port.rs485_supported = pci1xxxx_rs485_supported; 337 + 338 + ret = serial8250_pci_setup_port(pdev, port, 0, PORT_OFFSET * port_idx, 0); 339 + if (ret < 0) 340 + return ret; 341 + 342 + writeb(UART_BLOCK_SET_ACTIVE, port->port.membase + UART_ACTV_REG); 343 + writeb(UART_WAKE_SRCS, port->port.membase + UART_WAKE_REG); 344 + writeb(UART_WAKE_N_PIN, port->port.membase + UART_WAKE_MASK_REG); 345 + 346 + return 0; 347 + } 348 + 349 + static unsigned int pci1xxxx_get_max_port(int subsys_dev) 350 + { 351 + unsigned int i = MAX_PORTS; 352 + 353 + if (subsys_dev < ARRAY_SIZE(logical_to_physical_port_idx)) 354 + while (i--) { 355 + if (logical_to_physical_port_idx[subsys_dev][i] != -1) 356 + return logical_to_physical_port_idx[subsys_dev][i] + 1; 357 + } 358 + 359 + if (subsys_dev == PCI_SUBDEVICE_ID_EFAR_PCI11414) 360 + return 4; 361 + 362 + return 1; 363 + } 364 + 365 + static int pci1xxxx_logical_to_physical_port_translate(int subsys_dev, int port) 366 + { 367 + if (subsys_dev < ARRAY_SIZE(logical_to_physical_port_idx)) 368 + return logical_to_physical_port_idx[subsys_dev][port]; 369 + 370 + return logical_to_physical_port_idx[0][port]; 371 + } 372 + 373 + static int pci1xxxx_serial_probe(struct pci_dev *pdev, 374 + const struct pci_device_id *id) 375 + { 376 + struct device *dev = &pdev->dev; 377 + struct pci1xxxx_8250 *priv; 378 + struct uart_8250_port uart; 379 + unsigned int max_vec_reqd; 380 + unsigned int nr_ports, i; 381 + int num_vectors; 382 + int subsys_dev; 383 + int port_idx; 384 + int rc; 385 + 386 + rc = pcim_enable_device(pdev); 387 + if (rc) 388 + return rc; 389 + 390 + nr_ports = pci1xxxx_get_num_ports(pdev); 391 + 392 + priv = devm_kzalloc(dev, struct_size(priv, line, nr_ports), GFP_KERNEL); 393 + if (!priv) 394 + return -ENOMEM; 395 + 396 + priv->membase = pci_ioremap_bar(pdev, 0); 397 + if (!priv->membase) 398 + return -ENOMEM; 399 + 400 + pci_set_master(pdev); 401 + 402 + priv->nr = nr_ports; 403 + 404 + subsys_dev = pdev->subsystem_device; 405 + max_vec_reqd = pci1xxxx_get_max_port(subsys_dev); 406 + 407 + num_vectors = pci_alloc_irq_vectors(pdev, 1, max_vec_reqd, PCI_IRQ_ALL_TYPES); 408 + if (num_vectors < 0) { 409 + pci_iounmap(pdev, priv->membase); 410 + return num_vectors; 411 + } 412 + 413 + memset(&uart, 0, sizeof(uart)); 414 + uart.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT; 415 + uart.port.uartclk = UART_CLOCK_DEFAULT; 416 + uart.port.dev = dev; 417 + 418 + if (num_vectors == max_vec_reqd) 419 + writeb(UART_PCI_CTRL_SET_MULTIPLE_MSI, priv->membase + UART_PCI_CTRL_REG); 420 + 421 + for (i = 0; i < nr_ports; i++) { 422 + priv->line[i] = -ENODEV; 423 + 424 + port_idx = pci1xxxx_logical_to_physical_port_translate(subsys_dev, i); 425 + 426 + if (num_vectors == max_vec_reqd) 427 + uart.port.irq = pci_irq_vector(pdev, port_idx); 428 + else 429 + uart.port.irq = pci_irq_vector(pdev, 0); 430 + 431 + rc = pci1xxxx_setup(pdev, &uart, port_idx); 432 + if (rc) { 433 + dev_warn(dev, "Failed to setup port %u\n", i); 434 + continue; 435 + } 436 + 437 + priv->line[i] = serial8250_register_8250_port(&uart); 438 + if (priv->line[i] < 0) { 439 + dev_warn(dev, 440 + "Couldn't register serial port %lx, irq %d, type %d, error %d\n", 441 + uart.port.iobase, uart.port.irq, uart.port.iotype, 442 + priv->line[i]); 443 + } 444 + } 445 + 446 + pci_set_drvdata(pdev, priv); 447 + 448 + return 0; 449 + } 450 + 451 + static void pci1xxxx_serial_remove(struct pci_dev *dev) 452 + { 453 + struct pci1xxxx_8250 *priv = pci_get_drvdata(dev); 454 + unsigned int i; 455 + 456 + for (i = 0; i < priv->nr; i++) { 457 + if (priv->line[i] >= 0) 458 + serial8250_unregister_port(priv->line[i]); 459 + } 460 + 461 + pci_free_irq_vectors(dev); 462 + pci_iounmap(dev, priv->membase); 463 + } 464 + 465 + static DEFINE_SIMPLE_DEV_PM_OPS(pci1xxxx_pm_ops, pci1xxxx_suspend, pci1xxxx_resume); 466 + 467 + static const struct pci_device_id pci1xxxx_pci_tbl[] = { 468 + { PCI_VDEVICE(EFAR, PCI_DEVICE_ID_EFAR_PCI11010) }, 469 + { PCI_VDEVICE(EFAR, PCI_DEVICE_ID_EFAR_PCI11101) }, 470 + { PCI_VDEVICE(EFAR, PCI_DEVICE_ID_EFAR_PCI11400) }, 471 + { PCI_VDEVICE(EFAR, PCI_DEVICE_ID_EFAR_PCI11414) }, 472 + { PCI_VDEVICE(EFAR, PCI_DEVICE_ID_EFAR_PCI12000) }, 473 + {} 474 + }; 475 + MODULE_DEVICE_TABLE(pci, pci1xxxx_pci_tbl); 476 + 477 + static struct pci_driver pci1xxxx_pci_driver = { 478 + .name = "pci1xxxx serial", 479 + .probe = pci1xxxx_serial_probe, 480 + .remove = pci1xxxx_serial_remove, 481 + .driver = { 482 + .pm = pm_sleep_ptr(&pci1xxxx_pm_ops), 483 + }, 484 + .id_table = pci1xxxx_pci_tbl, 485 + }; 486 + module_pci_driver(pci1xxxx_pci_driver); 487 + 488 + static_assert((ARRAY_SIZE(logical_to_physical_port_idx) == PCI_SUBDEVICE_ID_EFAR_PCI1XXXX_1p3 + 1)); 489 + 490 + MODULE_IMPORT_NS(SERIAL_8250_PCI); 491 + MODULE_DESCRIPTION("Microchip Technology Inc. PCIe to UART module"); 492 + MODULE_AUTHOR("Kumaravel Thiagarajan <kumaravel.thiagarajan@microchip.com>"); 493 + MODULE_AUTHOR("Tharun Kumar P <tharunkumar.pasumarthi@microchip.com>"); 494 + MODULE_LICENSE("GPL");
+40
drivers/tty/serial/8250/8250_pcilib.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * 8250 PCI library. 4 + * 5 + * Copyright (C) 2001 Russell King, All Rights Reserved. 6 + */ 7 + #include <linux/errno.h> 8 + #include <linux/ioport.h> 9 + #include <linux/pci.h> 10 + #include <linux/types.h> 11 + 12 + #include "8250.h" 13 + #include "8250_pcilib.h" 14 + 15 + int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port, 16 + u8 bar, unsigned int offset, int regshift) 17 + { 18 + if (bar >= PCI_STD_NUM_BARS) 19 + return -EINVAL; 20 + 21 + if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) { 22 + if (!pcim_iomap(dev, bar, 0) && !pcim_iomap_table(dev)) 23 + return -ENOMEM; 24 + 25 + port->port.iotype = UPIO_MEM; 26 + port->port.iobase = 0; 27 + port->port.mapbase = pci_resource_start(dev, bar) + offset; 28 + port->port.membase = pcim_iomap_table(dev)[bar] + offset; 29 + port->port.regshift = regshift; 30 + } else { 31 + port->port.iotype = UPIO_PORT; 32 + port->port.iobase = pci_resource_start(dev, bar) + offset; 33 + port->port.mapbase = 0; 34 + port->port.membase = NULL; 35 + port->port.regshift = 0; 36 + } 37 + return 0; 38 + } 39 + EXPORT_SYMBOL_NS_GPL(serial8250_pci_setup_port, SERIAL_8250_PCI); 40 + MODULE_LICENSE("GPL");
+15
drivers/tty/serial/8250/8250_pcilib.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * 8250 PCI library header file. 4 + * 5 + * Copyright (C) 2001 Russell King, All Rights Reserved. 6 + */ 7 + 8 + #include <linux/types.h> 9 + 10 + struct pci_dev; 11 + 12 + struct uart_8250_port; 13 + 14 + int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port, u8 bar, 15 + unsigned int offset, int regshift);
+32 -25
drivers/tty/serial/8250/8250_port.c
··· 313 313 .rxtrig_bytes = {1, 4, 8, 14}, 314 314 .flags = UART_CAP_FIFO, 315 315 }, 316 + [PORT_MCHP16550A] = { 317 + .name = "MCHP16550A", 318 + .fifo_size = 256, 319 + .tx_loadsz = 256, 320 + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01, 321 + .rxtrig_bytes = {2, 66, 130, 194}, 322 + .flags = UART_CAP_FIFO, 323 + }, 316 324 }; 317 325 318 326 /* Uart divisor latch read */ ··· 1058 1050 serial_out(up, UART_LCR, 0); 1059 1051 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | 1060 1052 UART_FCR7_64BYTE); 1061 - status1 = serial_in(up, UART_IIR) >> 5; 1053 + status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | 1054 + UART_IIR_FIFO_ENABLED); 1062 1055 serial_out(up, UART_FCR, 0); 1063 1056 serial_out(up, UART_LCR, 0); 1064 1057 1065 - if (status1 == 7) 1058 + if (status1 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED)) 1066 1059 up->port.type = PORT_16550A_FSL64; 1067 1060 else 1068 1061 DEBUG_AUTOCONF("Motorola 8xxx DUART "); ··· 1131 1122 */ 1132 1123 serial_out(up, UART_LCR, 0); 1133 1124 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); 1134 - status1 = serial_in(up, UART_IIR) >> 5; 1125 + status1 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED); 1135 1126 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1127 + 1136 1128 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); 1137 1129 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); 1138 - status2 = serial_in(up, UART_IIR) >> 5; 1130 + status2 = serial_in(up, UART_IIR) & (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED); 1139 1131 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1132 + 1140 1133 serial_out(up, UART_LCR, 0); 1141 1134 1142 1135 DEBUG_AUTOCONF("iir1=%d iir2=%d ", status1, status2); 1143 1136 1144 - if (status1 == 6 && status2 == 7) { 1137 + if (status1 == UART_IIR_FIFO_ENABLED_16550A && 1138 + status2 == (UART_IIR_64BYTE_FIFO | UART_IIR_FIFO_ENABLED_16550A)) { 1145 1139 up->port.type = PORT_16750; 1146 1140 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; 1147 1141 return; ··· 1248 1236 * Mask out IER[7:4] bits for test as some UARTs (e.g. TL 1249 1237 * 16C754B) allow only to modify them if an EFR bit is set. 1250 1238 */ 1251 - scratch2 = serial_in(up, UART_IER) & 0x0f; 1252 - serial_out(up, UART_IER, 0x0F); 1239 + scratch2 = serial_in(up, UART_IER) & UART_IER_ALL_INTR; 1240 + serial_out(up, UART_IER, UART_IER_ALL_INTR); 1253 1241 #ifdef __i386__ 1254 1242 outb(0, 0x080); 1255 1243 #endif 1256 - scratch3 = serial_in(up, UART_IER) & 0x0f; 1244 + scratch3 = serial_in(up, UART_IER) & UART_IER_ALL_INTR; 1257 1245 serial_out(up, UART_IER, scratch); 1258 - if (scratch2 != 0 || scratch3 != 0x0F) { 1246 + if (scratch2 != 0 || scratch3 != UART_IER_ALL_INTR) { 1259 1247 /* 1260 1248 * We failed; there's nothing here 1261 1249 */ ··· 1279 1267 * that conflicts with COM 1-4 --- we hope! 1280 1268 */ 1281 1269 if (!(port->flags & UPF_SKIP_TEST)) { 1282 - serial8250_out_MCR(up, UART_MCR_LOOP | 0x0A); 1283 - status1 = serial_in(up, UART_MSR) & 0xF0; 1270 + serial8250_out_MCR(up, UART_MCR_LOOP | UART_MCR_OUT2 | UART_MCR_RTS); 1271 + status1 = serial_in(up, UART_MSR) & UART_MSR_STATUS_BITS; 1284 1272 serial8250_out_MCR(up, save_mcr); 1285 - if (status1 != 0x90) { 1273 + if (status1 != (UART_MSR_DCD | UART_MSR_CTS)) { 1286 1274 spin_unlock_irqrestore(&port->lock, flags); 1287 1275 DEBUG_AUTOCONF("LOOP test failed (%02x) ", 1288 1276 status1); ··· 1305 1293 1306 1294 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1307 1295 1308 - /* Assign this as it is to truncate any bits above 7. */ 1309 - scratch = serial_in(up, UART_IIR); 1310 - 1311 - switch (scratch >> 6) { 1312 - case 0: 1296 + switch (serial_in(up, UART_IIR) & UART_IIR_FIFO_ENABLED) { 1297 + case UART_IIR_FIFO_ENABLED_8250: 1313 1298 autoconfig_8250(up); 1314 1299 break; 1315 - case 1: 1316 - port->type = PORT_UNKNOWN; 1317 - break; 1318 - case 2: 1300 + case UART_IIR_FIFO_ENABLED_16550: 1319 1301 port->type = PORT_16550; 1320 1302 break; 1321 - case 3: 1303 + case UART_IIR_FIFO_ENABLED_16550A: 1322 1304 autoconfig_16550a(up); 1305 + break; 1306 + default: 1307 + port->type = PORT_UNKNOWN; 1323 1308 break; 1324 1309 } 1325 1310 ··· 1403 1394 serial8250_out_MCR(up, 1404 1395 UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2); 1405 1396 } 1406 - serial_out(up, UART_IER, 0x0f); /* enable all intrs */ 1397 + serial_out(up, UART_IER, UART_IER_ALL_INTR); 1407 1398 serial_in(up, UART_LSR); 1408 1399 serial_in(up, UART_RX); 1409 1400 serial_in(up, UART_IIR); ··· 1519 1510 if (em485) { 1520 1511 u16 lsr = serial_lsr_in(p); 1521 1512 u64 stop_delay = 0; 1522 - 1523 - p->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; 1524 1513 1525 1514 if (!(lsr & UART_LSR_THRE)) 1526 1515 return;
+27
drivers/tty/serial/8250/Kconfig
··· 129 129 This builds DMA support that can be used with 8250/16650 130 130 compatible UART controllers that support DMA signaling. 131 131 132 + config SERIAL_8250_PCILIB 133 + bool 134 + 132 135 config SERIAL_8250_PCI 133 136 tristate "8250/16550 PCI device support" 134 137 depends on SERIAL_8250 && PCI 138 + select SERIAL_8250_PCILIB 135 139 default SERIAL_8250 136 140 help 137 141 This builds standard PCI serial support. You may be able to ··· 295 291 To compile this driver as a module, choose M here: the module 296 292 will be called 8250_hub6. 297 293 294 + config SERIAL_8250_PCI1XXXX 295 + tristate "Microchip 8250 based serial port" 296 + depends on SERIAL_8250 && PCI 297 + select SERIAL_8250_PCILIB 298 + default SERIAL_8250 299 + help 300 + Select this option if you have a setup with Microchip PCIe 301 + Switch with serial port enabled and wish to enable 8250 302 + serial driver for the serial interface. This driver support 303 + will ensure to support baud rates upto 1.5Mpbs. 304 + 298 305 # 299 306 # Misc. options/drivers. 300 307 # ··· 384 369 Selecting this option enables a workaround for a break-detection 385 370 erratum for Freescale 16550 UARTs in the 8250 driver. It also 386 371 enables support for ACPI enumeration. 372 + 373 + config SERIAL_8250_DFL 374 + tristate "DFL bus driver for Altera 16550 UART" 375 + depends on SERIAL_8250 && FPGA_DFL 376 + help 377 + This option enables support for a Device Feature List (DFL) bus 378 + driver for the Altera 16550 UART. One or more Altera 16550 UARTs 379 + can be instantiated in a FPGA and then be discovered during 380 + enumeration of the DFL bus. 381 + 382 + To compile this driver as a module, chose M here: the 383 + module will be called 8250_dfl. 387 384 388 385 config SERIAL_8250_DW 389 386 tristate "Support for Synopsys DesignWare 8250 quirks"
+3
drivers/tty/serial/8250/Makefile
··· 12 12 8250_base-$(CONFIG_SERIAL_8250_DMA) += 8250_dma.o 13 13 8250_base-$(CONFIG_SERIAL_8250_DWLIB) += 8250_dwlib.o 14 14 8250_base-$(CONFIG_SERIAL_8250_FINTEK) += 8250_fintek.o 15 + 8250_base-$(CONFIG_SERIAL_8250_PCILIB) += 8250_pcilib.o 15 16 obj-$(CONFIG_SERIAL_8250_PARISC) += 8250_parisc.o 16 17 obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o 17 18 obj-$(CONFIG_SERIAL_8250_EXAR) += 8250_exar.o ··· 27 26 obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o 28 27 obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o 29 28 obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o 29 + obj-$(CONFIG_SERIAL_8250_PCI1XXXX) += 8250_pci1xxxx.o 30 30 obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o 31 31 obj-$(CONFIG_SERIAL_8250_MEN_MCB) += 8250_men_mcb.o 32 + obj-$(CONFIG_SERIAL_8250_DFL) += 8250_dfl.o 32 33 obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o 33 34 obj-$(CONFIG_SERIAL_8250_EM) += 8250_em.o 34 35 obj-$(CONFIG_SERIAL_8250_IOC3) += 8250_ioc3.o
+8 -8
drivers/tty/serial/Kconfig
··· 73 73 your boot loader (lilo or loadlin) about how to pass options to the 74 74 kernel at boot time.) 75 75 76 - config SERIAL_EARLYCON_ARM_SEMIHOST 77 - bool "Early console using ARM semihosting" 78 - depends on ARM64 || ARM 76 + config SERIAL_EARLYCON_SEMIHOST 77 + bool "Early console using Arm compatible semihosting" 78 + depends on ARM64 || ARM || RISCV 79 79 select SERIAL_CORE 80 80 select SERIAL_CORE_CONSOLE 81 81 select SERIAL_EARLYCON 82 82 help 83 - Support for early debug console using ARM semihosting. This enables 84 - the console before standard serial driver is probed. This is enabled 85 - with "earlycon=smh" on the kernel command line. The console is 86 - enabled when early_param is processed. 83 + Support for early debug console using Arm compatible semihosting. 84 + This enables the console before standard serial driver is probed. 85 + This is enabled with "earlycon=smh" on the kernel command line. 86 + The console is enabled when early_param is processed. 87 87 88 88 config SERIAL_EARLYCON_RISCV_SBI 89 89 bool "Early console using RISC-V SBI" ··· 1507 1507 config SERIAL_LITEUART 1508 1508 tristate "LiteUART serial port support" 1509 1509 depends on HAS_IOMEM 1510 - depends on OF || COMPILE_TEST 1510 + depends on OF 1511 1511 depends on LITEX || COMPILE_TEST 1512 1512 select SERIAL_CORE 1513 1513 help
+1 -1
drivers/tty/serial/Makefile
··· 6 6 obj-$(CONFIG_SERIAL_CORE) += serial_core.o 7 7 8 8 obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o 9 - obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o 9 + obj-$(CONFIG_SERIAL_EARLYCON_SEMIHOST) += earlycon-semihost.o 10 10 obj-$(CONFIG_SERIAL_EARLYCON_RISCV_SBI) += earlycon-riscv-sbi.o 11 11 12 12 # These Sparc drivers have to appear before others such as 8250
+1 -24
drivers/tty/serial/earlycon-arm-semihost.c drivers/tty/serial/earlycon-semihost.c
··· 11 11 #include <linux/console.h> 12 12 #include <linux/init.h> 13 13 #include <linux/serial_core.h> 14 - 15 - #ifdef CONFIG_THUMB2_KERNEL 16 - #define SEMIHOST_SWI "0xab" 17 - #else 18 - #define SEMIHOST_SWI "0x123456" 19 - #endif 20 - 21 - /* 22 - * Semihosting-based debug console 23 - */ 24 - static void smh_putc(struct uart_port *port, unsigned char c) 25 - { 26 - #ifdef CONFIG_ARM64 27 - asm volatile("mov x1, %0\n" 28 - "mov x0, #3\n" 29 - "hlt 0xf000\n" 30 - : : "r" (&c) : "x0", "x1", "memory"); 31 - #else 32 - asm volatile("mov r1, %0\n" 33 - "mov r0, #3\n" 34 - "svc " SEMIHOST_SWI "\n" 35 - : : "r" (&c) : "r0", "r1", "memory"); 36 - #endif 37 - } 14 + #include <asm/semihost.h> 38 15 39 16 static void smh_write(struct console *con, const char *s, unsigned n) 40 17 {
+8 -1
drivers/tty/serial/earlycon.c
··· 120 120 } 121 121 122 122 if (options) { 123 + char *uartclk; 124 + 123 125 device->baud = simple_strtoul(options, NULL, 0); 126 + uartclk = strchr(options, ','); 127 + if (uartclk && kstrtouint(uartclk + 1, 0, &port->uartclk) < 0) 128 + pr_warn("[%s] unsupported earlycon uart clkrate option\n", 129 + options); 124 130 length = min(strcspn(options, " ") + 1, 125 131 (size_t)(sizeof(device->options))); 126 132 strscpy(device->options, options, length); ··· 145 139 buf = NULL; 146 140 147 141 spin_lock_init(&port->lock); 148 - port->uartclk = BASE_BAUD * 16; 142 + if (!port->uartclk) 143 + port->uartclk = BASE_BAUD * 16; 149 144 if (port->mapbase) 150 145 port->membase = earlycon_map(port->mapbase, 64); 151 146
+97 -22
drivers/tty/serial/fsl_lpuart.c
··· 5 5 * Copyright 2012-2014 Freescale Semiconductor, Inc. 6 6 */ 7 7 8 + #include <linux/bitfield.h> 9 + #include <linux/bits.h> 8 10 #include <linux/clk.h> 9 11 #include <linux/console.h> 10 12 #include <linux/delay.h> ··· 183 181 #define UARTCTRL_SBK 0x00010000 184 182 #define UARTCTRL_MA1IE 0x00008000 185 183 #define UARTCTRL_MA2IE 0x00004000 186 - #define UARTCTRL_IDLECFG 0x00000100 184 + #define UARTCTRL_IDLECFG GENMASK(10, 8) 187 185 #define UARTCTRL_LOOPS 0x00000080 188 186 #define UARTCTRL_DOZEEN 0x00000040 189 187 #define UARTCTRL_RSRC 0x00000020 ··· 201 199 #define UARTDATA_MASK 0x3ff 202 200 203 201 #define UARTMODIR_IREN 0x00020000 202 + #define UARTMODIR_RTSWATER GENMASK(10, 8) 204 203 #define UARTMODIR_TXCTSSRC 0x00000020 205 204 #define UARTMODIR_TXCTSC 0x00000010 206 205 #define UARTMODIR_RXRTSE 0x00000008 ··· 215 212 #define UARTFIFO_RXUF 0x00010000 216 213 #define UARTFIFO_TXFLUSH 0x00008000 217 214 #define UARTFIFO_RXFLUSH 0x00004000 215 + #define UARTFIFO_RXIDEN GENMASK(12, 10) 218 216 #define UARTFIFO_TXOFE 0x00000200 219 217 #define UARTFIFO_RXUFE 0x00000100 220 218 #define UARTFIFO_TXFE 0x00000080 ··· 242 238 243 239 #define DRIVER_NAME "fsl-lpuart" 244 240 #define DEV_NAME "ttyLP" 245 - #define UART_NR 6 241 + #define UART_NR 8 246 242 247 243 /* IMX lpuart has four extra unused regs located at the beginning */ 248 244 #define IMX_REG_OFF 0x10 ··· 252 248 LS1021A_LPUART, 253 249 LS1028A_LPUART, 254 250 IMX7ULP_LPUART, 251 + IMX8ULP_LPUART, 255 252 IMX8QXP_LPUART, 256 253 IMXRT1050_LPUART, 257 254 }; ··· 265 260 unsigned int txfifo_size; 266 261 unsigned int rxfifo_size; 267 262 263 + u8 rx_watermark; 268 264 bool lpuart_dma_tx_use; 269 265 bool lpuart_dma_rx_use; 270 266 struct dma_chan *dma_tx_chan; ··· 292 286 enum lpuart_type devtype; 293 287 char iotype; 294 288 u8 reg_off; 289 + u8 rx_watermark; 295 290 }; 296 291 297 292 static const struct lpuart_soc_data vf_data = { 298 293 .devtype = VF610_LPUART, 299 294 .iotype = UPIO_MEM, 295 + .rx_watermark = 1, 300 296 }; 301 297 302 298 static const struct lpuart_soc_data ls1021a_data = { 303 299 .devtype = LS1021A_LPUART, 304 300 .iotype = UPIO_MEM32BE, 301 + .rx_watermark = 1, 305 302 }; 306 303 307 304 static const struct lpuart_soc_data ls1028a_data = { 308 305 .devtype = LS1028A_LPUART, 309 306 .iotype = UPIO_MEM32, 307 + .rx_watermark = 1, 310 308 }; 311 309 312 310 static struct lpuart_soc_data imx7ulp_data = { 313 311 .devtype = IMX7ULP_LPUART, 314 312 .iotype = UPIO_MEM32, 315 313 .reg_off = IMX_REG_OFF, 314 + .rx_watermark = 1, 315 + }; 316 + 317 + static struct lpuart_soc_data imx8ulp_data = { 318 + .devtype = IMX8ULP_LPUART, 319 + .iotype = UPIO_MEM32, 320 + .reg_off = IMX_REG_OFF, 321 + .rx_watermark = 3, 316 322 }; 317 323 318 324 static struct lpuart_soc_data imx8qxp_data = { 319 325 .devtype = IMX8QXP_LPUART, 320 326 .iotype = UPIO_MEM32, 321 327 .reg_off = IMX_REG_OFF, 328 + .rx_watermark = 31, 322 329 }; 323 330 static struct lpuart_soc_data imxrt1050_data = { 324 331 .devtype = IMXRT1050_LPUART, 325 332 .iotype = UPIO_MEM32, 326 333 .reg_off = IMX_REG_OFF, 334 + .rx_watermark = 1, 327 335 }; 328 336 329 337 static const struct of_device_id lpuart_dt_ids[] = { ··· 345 325 { .compatible = "fsl,ls1021a-lpuart", .data = &ls1021a_data, }, 346 326 { .compatible = "fsl,ls1028a-lpuart", .data = &ls1028a_data, }, 347 327 { .compatible = "fsl,imx7ulp-lpuart", .data = &imx7ulp_data, }, 328 + { .compatible = "fsl,imx8ulp-lpuart", .data = &imx8ulp_data, }, 348 329 { .compatible = "fsl,imx8qxp-lpuart", .data = &imx8qxp_data, }, 349 330 { .compatible = "fsl,imxrt1050-lpuart", .data = &imxrt1050_data}, 350 331 { /* sentinel */ } ··· 364 343 static inline bool is_imx7ulp_lpuart(struct lpuart_port *sport) 365 344 { 366 345 return sport->devtype == IMX7ULP_LPUART; 346 + } 347 + 348 + static inline bool is_imx8ulp_lpuart(struct lpuart_port *sport) 349 + { 350 + return sport->devtype == IMX8ULP_LPUART; 367 351 } 368 352 369 353 static inline bool is_imx8qxp_lpuart(struct lpuart_port *sport) ··· 1413 1387 * Note: UART is assumed to be active high. 1414 1388 */ 1415 1389 if (rs485->flags & SER_RS485_RTS_ON_SEND) 1416 - modem &= ~UARTMODEM_TXRTSPOL; 1417 - else if (rs485->flags & SER_RS485_RTS_AFTER_SEND) 1418 1390 modem |= UARTMODEM_TXRTSPOL; 1391 + else if (rs485->flags & SER_RS485_RTS_AFTER_SEND) 1392 + modem &= ~UARTMODEM_TXRTSPOL; 1419 1393 } 1420 1394 1421 1395 lpuart32_write(&sport->port, modem, UARTMODIR); ··· 1488 1462 1489 1463 static void lpuart32_break_ctl(struct uart_port *port, int break_state) 1490 1464 { 1491 - unsigned long temp; 1465 + unsigned long temp, modem; 1466 + struct tty_struct *tty; 1467 + unsigned int cflag = 0; 1468 + 1469 + tty = tty_port_tty_get(&port->state->port); 1470 + if (tty) { 1471 + cflag = tty->termios.c_cflag; 1472 + tty_kref_put(tty); 1473 + } 1492 1474 1493 1475 temp = lpuart32_read(port, UARTCTRL) & ~UARTCTRL_SBK; 1476 + modem = lpuart32_read(port, UARTMODIR); 1494 1477 1495 - if (break_state != 0) 1478 + if (break_state != 0) { 1496 1479 temp |= UARTCTRL_SBK; 1480 + /* 1481 + * LPUART CTS has higher priority than SBK, need to disable CTS before 1482 + * asserting SBK to avoid any interference if flow control is enabled. 1483 + */ 1484 + if (cflag & CRTSCTS && modem & UARTMODIR_TXCTSE) 1485 + lpuart32_write(port, modem & ~UARTMODIR_TXCTSE, UARTMODIR); 1486 + } else { 1487 + /* Re-enable the CTS when break off. */ 1488 + if (cflag & CRTSCTS && !(modem & UARTMODIR_TXCTSE)) 1489 + lpuart32_write(port, modem | UARTMODIR_TXCTSE, UARTMODIR); 1490 + } 1497 1491 1498 1492 lpuart32_write(port, temp, UARTCTRL); 1499 1493 } ··· 1543 1497 writeb(UARTSFIFO_RXUF, sport->port.membase + UARTSFIFO); 1544 1498 } 1545 1499 1500 + if (uart_console(&sport->port)) 1501 + sport->rx_watermark = 1; 1546 1502 writeb(0, sport->port.membase + UARTTWFIFO); 1547 - writeb(1, sport->port.membase + UARTRWFIFO); 1503 + writeb(sport->rx_watermark, sport->port.membase + UARTRWFIFO); 1548 1504 1549 1505 /* Restore cr2 */ 1550 1506 writeb(cr2_saved, sport->port.membase + UARTCR2); ··· 1571 1523 ctrl = lpuart32_read(&sport->port, UARTCTRL); 1572 1524 ctrl_saved = ctrl; 1573 1525 ctrl &= ~(UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_TE | 1574 - UARTCTRL_RIE | UARTCTRL_RE); 1526 + UARTCTRL_RIE | UARTCTRL_RE | UARTCTRL_ILIE); 1575 1527 lpuart32_write(&sport->port, ctrl, UARTCTRL); 1576 1528 1577 1529 /* enable FIFO mode */ 1578 1530 val = lpuart32_read(&sport->port, UARTFIFO); 1579 1531 val |= UARTFIFO_TXFE | UARTFIFO_RXFE; 1580 1532 val |= UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH; 1533 + val |= FIELD_PREP(UARTFIFO_RXIDEN, 0x3); 1581 1534 lpuart32_write(&sport->port, val, UARTFIFO); 1582 1535 1583 1536 /* set the watermark */ 1584 - val = (0x1 << UARTWATER_RXWATER_OFF) | (0x0 << UARTWATER_TXWATER_OFF); 1537 + if (uart_console(&sport->port)) 1538 + sport->rx_watermark = 1; 1539 + val = (sport->rx_watermark << UARTWATER_RXWATER_OFF) | 1540 + (0x0 << UARTWATER_TXWATER_OFF); 1585 1541 lpuart32_write(&sport->port, val, UARTWATER); 1542 + 1543 + /* set RTS watermark */ 1544 + if (!uart_console(&sport->port)) { 1545 + val = lpuart32_read(&sport->port, UARTMODIR); 1546 + val |= FIELD_PREP(UARTMODIR_RTSWATER, sport->rxfifo_size >> 1); 1547 + lpuart32_write(&sport->port, val, UARTMODIR); 1548 + } 1586 1549 1587 1550 /* Restore cr2 */ 1588 1551 lpuart32_write(&sport->port, ctrl_saved, UARTCTRL); ··· 1606 1547 lpuart32_setup_watermark(sport); 1607 1548 1608 1549 temp = lpuart32_read(&sport->port, UARTCTRL); 1609 - temp |= UARTCTRL_RE | UARTCTRL_TE | UARTCTRL_ILIE; 1550 + temp |= UARTCTRL_RE | UARTCTRL_TE; 1551 + temp |= FIELD_PREP(UARTCTRL_IDLECFG, 0x7); 1610 1552 lpuart32_write(&sport->port, temp, UARTCTRL); 1611 1553 } 1612 1554 ··· 1739 1679 return 0; 1740 1680 } 1741 1681 1682 + static void lpuart32_hw_disable(struct lpuart_port *sport) 1683 + { 1684 + unsigned long temp; 1685 + 1686 + temp = lpuart32_read(&sport->port, UARTCTRL); 1687 + temp &= ~(UARTCTRL_RIE | UARTCTRL_ILIE | UARTCTRL_RE | 1688 + UARTCTRL_TIE | UARTCTRL_TE); 1689 + lpuart32_write(&sport->port, temp, UARTCTRL); 1690 + } 1691 + 1742 1692 static void lpuart32_configure(struct lpuart_port *sport) 1743 1693 { 1744 1694 unsigned long temp; 1745 1695 1746 - if (sport->lpuart_dma_rx_use) { 1747 - /* RXWATER must be 0 */ 1748 - temp = lpuart32_read(&sport->port, UARTWATER); 1749 - temp &= ~(UARTWATER_WATER_MASK << UARTWATER_RXWATER_OFF); 1750 - lpuart32_write(&sport->port, temp, UARTWATER); 1751 - } 1752 1696 temp = lpuart32_read(&sport->port, UARTCTRL); 1753 1697 if (!sport->lpuart_dma_rx_use) 1754 - temp |= UARTCTRL_RIE; 1698 + temp |= UARTCTRL_RIE | UARTCTRL_ILIE; 1755 1699 if (!sport->lpuart_dma_tx_use) 1756 1700 temp |= UARTCTRL_TIE; 1757 1701 lpuart32_write(&sport->port, temp, UARTCTRL); ··· 1767 1703 1768 1704 spin_lock_irqsave(&sport->port.lock, flags); 1769 1705 1770 - lpuart32_setup_watermark_enable(sport); 1706 + lpuart32_hw_disable(sport); 1771 1707 1772 1708 lpuart_rx_dma_startup(sport); 1773 1709 lpuart_tx_dma_startup(sport); 1774 1710 1711 + lpuart32_setup_watermark_enable(sport); 1775 1712 lpuart32_configure(sport); 1776 1713 1777 1714 spin_unlock_irqrestore(&sport->port.lock, flags); ··· 1861 1796 1862 1797 spin_lock_irqsave(&port->lock, flags); 1863 1798 1864 - /* disable Rx/Tx and interrupts */ 1799 + /* clear status */ 1800 + temp = lpuart32_read(&sport->port, UARTSTAT); 1801 + lpuart32_write(&sport->port, temp, UARTSTAT); 1802 + 1803 + /* disable Rx/Tx DMA */ 1804 + temp = lpuart32_read(port, UARTBAUD); 1805 + temp &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE); 1806 + lpuart32_write(port, temp, UARTBAUD); 1807 + 1808 + /* disable Rx/Tx and interrupts and break condition */ 1865 1809 temp = lpuart32_read(port, UARTCTRL); 1866 - temp &= ~(UARTCTRL_TE | UARTCTRL_RE | 1867 - UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE); 1810 + temp &= ~(UARTCTRL_TE | UARTCTRL_RE | UARTCTRL_ILIE | 1811 + UARTCTRL_TIE | UARTCTRL_TCIE | UARTCTRL_RIE | UARTCTRL_SBK); 1868 1812 lpuart32_write(port, temp, UARTCTRL); 1869 1813 1870 1814 spin_unlock_irqrestore(&port->lock, flags); ··· 2705 2631 return ret; 2706 2632 } 2707 2633 2708 - if (is_imx7ulp_lpuart(sport) || is_imx8qxp_lpuart(sport)) { 2634 + if (is_imx7ulp_lpuart(sport) || is_imx8ulp_lpuart(sport) || is_imx8qxp_lpuart(sport)) { 2709 2635 /* 2710 2636 * If the transmitter is used by earlycon, wait for transmit engine to 2711 2637 * complete and then reset. ··· 2762 2688 sport->port.dev = &pdev->dev; 2763 2689 sport->port.type = PORT_LPUART; 2764 2690 sport->devtype = sdata->devtype; 2691 + sport->rx_watermark = sdata->rx_watermark; 2765 2692 ret = platform_get_irq(pdev, 0); 2766 2693 if (ret < 0) 2767 2694 return ret;
+156 -150
drivers/tty/serial/imx.c
··· 210 210 211 211 struct mctrl_gpios *gpios; 212 212 213 - /* shadow registers */ 214 - unsigned int ucr1; 215 - unsigned int ucr2; 216 - unsigned int ucr3; 217 - unsigned int ucr4; 218 - unsigned int ufcr; 213 + /* counter to stop 0xff flood */ 214 + int idle_counter; 219 215 220 216 /* DMA fields */ 221 217 unsigned int dma_is_enabled:1; ··· 269 273 }; 270 274 MODULE_DEVICE_TABLE(of, imx_uart_dt_ids); 271 275 272 - static void imx_uart_writel(struct imx_port *sport, u32 val, u32 offset) 276 + static inline void imx_uart_writel(struct imx_port *sport, u32 val, u32 offset) 273 277 { 274 - switch (offset) { 275 - case UCR1: 276 - sport->ucr1 = val; 277 - break; 278 - case UCR2: 279 - sport->ucr2 = val; 280 - break; 281 - case UCR3: 282 - sport->ucr3 = val; 283 - break; 284 - case UCR4: 285 - sport->ucr4 = val; 286 - break; 287 - case UFCR: 288 - sport->ufcr = val; 289 - break; 290 - default: 291 - break; 292 - } 293 278 writel(val, sport->port.membase + offset); 294 279 } 295 280 296 - static u32 imx_uart_readl(struct imx_port *sport, u32 offset) 281 + static inline u32 imx_uart_readl(struct imx_port *sport, u32 offset) 297 282 { 298 - switch (offset) { 299 - case UCR1: 300 - return sport->ucr1; 301 - break; 302 - case UCR2: 303 - /* 304 - * UCR2_SRST is the only bit in the cached registers that might 305 - * differ from the value that was last written. As it only 306 - * automatically becomes one after being cleared, reread 307 - * conditionally. 308 - */ 309 - if (!(sport->ucr2 & UCR2_SRST)) 310 - sport->ucr2 = readl(sport->port.membase + offset); 311 - return sport->ucr2; 312 - break; 313 - case UCR3: 314 - return sport->ucr3; 315 - break; 316 - case UCR4: 317 - return sport->ucr4; 318 - break; 319 - case UFCR: 320 - return sport->ufcr; 321 - break; 322 - default: 323 - return readl(sport->port.membase + offset); 324 - } 283 + return readl(sport->port.membase + offset); 325 284 } 326 285 327 286 static inline unsigned imx_uart_uts_reg(struct imx_port *sport) ··· 346 395 static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec) 347 396 { 348 397 hrtimer_start(hrt, ms_to_ktime(msec), HRTIMER_MODE_REL); 398 + } 399 + 400 + /* called with port.lock taken and irqs off */ 401 + static void imx_uart_soft_reset(struct imx_port *sport) 402 + { 403 + int i = 10; 404 + u32 ucr2, ubir, ubmr, uts; 405 + 406 + /* 407 + * According to the Reference Manual description of the UART SRST bit: 408 + * 409 + * "Reset the transmit and receive state machines, 410 + * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD 411 + * and UTS[6-3]". 412 + * 413 + * We don't need to restore the old values from USR1, USR2, URXD and 414 + * UTXD. UBRC is read only, so only save/restore the other three 415 + * registers. 416 + */ 417 + ubir = imx_uart_readl(sport, UBIR); 418 + ubmr = imx_uart_readl(sport, UBMR); 419 + uts = imx_uart_readl(sport, IMX21_UTS); 420 + 421 + ucr2 = imx_uart_readl(sport, UCR2); 422 + imx_uart_writel(sport, ucr2 & ~UCR2_SRST, UCR2); 423 + 424 + while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) 425 + udelay(1); 426 + 427 + /* Restore the registers */ 428 + imx_uart_writel(sport, ubir, UBIR); 429 + imx_uart_writel(sport, ubmr, UBMR); 430 + imx_uart_writel(sport, uts, IMX21_UTS); 431 + 432 + sport->idle_counter = 0; 349 433 } 350 434 351 435 /* called with port.lock taken and irqs off */ ··· 462 476 imx_uart_rts_inactive(sport, &ucr2); 463 477 imx_uart_writel(sport, ucr2, UCR2); 464 478 465 - imx_uart_start_rx(port); 479 + if (!port->rs485_rx_during_tx_gpio) 480 + imx_uart_start_rx(port); 466 481 467 482 sport->tx_state = OFF; 468 483 } ··· 692 705 imx_uart_rts_inactive(sport, &ucr2); 693 706 imx_uart_writel(sport, ucr2, UCR2); 694 707 695 - if (!(port->rs485.flags & SER_RS485_RX_DURING_TX)) 708 + if (!(port->rs485.flags & SER_RS485_RX_DURING_TX) && 709 + !port->rs485_rx_during_tx_gpio) 696 710 imx_uart_stop_rx(port); 697 711 698 712 sport->tx_state = WAIT_AFTER_RTS; ··· 759 771 760 772 imx_uart_writel(sport, USR1_RTSD, USR1); 761 773 usr1 = imx_uart_readl(sport, USR1) & USR1_RTSS; 762 - uart_handle_cts_change(&sport->port, !!usr1); 774 + uart_handle_cts_change(&sport->port, usr1); 763 775 wake_up_interruptible(&sport->port.state->port.delta_msr_wait); 764 776 765 777 return IRQ_HANDLED; ··· 789 801 return IRQ_HANDLED; 790 802 } 791 803 804 + /* Check if hardware Rx flood is in progress, and issue soft reset to stop it. 805 + * This is to be called from Rx ISRs only when some bytes were actually 806 + * received. 807 + * 808 + * A way to reproduce the flood (checked on iMX6SX) is: open iMX UART at 9600 809 + * 8N1, and from external source send 0xf0 char at 115200 8N1. In about 90% of 810 + * cases this starts a flood of "receiving" of 0xff characters by the iMX6 UART 811 + * that is terminated by any activity on RxD line, or could be stopped by 812 + * issuing soft reset to the UART (just stop/start of RX does not help). Note 813 + * that what we do here is sending isolated start bit about 2.4 times shorter 814 + * than it is to be on UART configured baud rate. 815 + */ 816 + static void imx_uart_check_flood(struct imx_port *sport, u32 usr2) 817 + { 818 + /* To detect hardware 0xff flood we monitor RxD line between RX 819 + * interrupts to isolate "receiving" of char(s) with no activity 820 + * on RxD line, that'd never happen on actual data transfers. 821 + * 822 + * We use USR2_WAKE bit to check for activity on RxD line, but we have a 823 + * race here if we clear USR2_WAKE when receiving of a char is in 824 + * progress, so we might get RX interrupt later with USR2_WAKE bit 825 + * cleared. Note though that as we don't try to clear USR2_WAKE when we 826 + * detected no activity, this race may hide actual activity only once. 827 + * 828 + * Yet another case where receive interrupt may occur without RxD 829 + * activity is expiration of aging timer, so we consider this as well. 830 + * 831 + * We use 'idle_counter' to ensure that we got at least so many RX 832 + * interrupts without any detected activity on RxD line. 2 cases 833 + * described plus 1 to be on the safe side gives us a margin of 3, 834 + * below. In practice I was not able to produce a false positive to 835 + * induce soft reset at regular data transfers even using 1 as the 836 + * margin, so 3 is actually very strong. 837 + * 838 + * We count interrupts, not chars in 'idle-counter' for simplicity. 839 + */ 840 + 841 + if (usr2 & USR2_WAKE) { 842 + imx_uart_writel(sport, USR2_WAKE, USR2); 843 + sport->idle_counter = 0; 844 + } else if (++sport->idle_counter > 3) { 845 + dev_warn(sport->port.dev, "RX flood detected: soft reset."); 846 + imx_uart_soft_reset(sport); /* also clears 'sport->idle_counter' */ 847 + } 848 + } 849 + 792 850 static irqreturn_t __imx_uart_rxint(int irq, void *dev_id) 793 851 { 794 852 struct imx_port *sport = dev_id; 795 - unsigned int rx, flg, ignored = 0; 796 853 struct tty_port *port = &sport->port.state->port; 854 + u32 usr2, rx; 797 855 798 - while (imx_uart_readl(sport, USR2) & USR2_RDR) { 799 - u32 usr2; 856 + /* If we received something, check for 0xff flood */ 857 + usr2 = imx_uart_readl(sport, USR2); 858 + if (usr2 & USR2_RDR) 859 + imx_uart_check_flood(sport, usr2); 800 860 801 - flg = TTY_NORMAL; 861 + while ((rx = imx_uart_readl(sport, URXD0)) & URXD_CHARRDY) { 862 + unsigned int flg = TTY_NORMAL; 802 863 sport->port.icount.rx++; 803 864 804 - rx = imx_uart_readl(sport, URXD0); 805 - 806 - usr2 = imx_uart_readl(sport, USR2); 807 - if (usr2 & USR2_BRCD) { 808 - imx_uart_writel(sport, USR2_BRCD, USR2); 809 - if (uart_handle_break(&sport->port)) 810 - continue; 811 - } 812 - 813 - if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) 814 - continue; 815 - 816 865 if (unlikely(rx & URXD_ERR)) { 817 - if (rx & URXD_BRK) 866 + if (rx & URXD_BRK) { 818 867 sport->port.icount.brk++; 868 + if (uart_handle_break(&sport->port)) 869 + continue; 870 + } 819 871 else if (rx & URXD_PRERR) 820 872 sport->port.icount.parity++; 821 873 else if (rx & URXD_FRMERR) ··· 863 835 if (rx & URXD_OVRRUN) 864 836 sport->port.icount.overrun++; 865 837 866 - if (rx & sport->port.ignore_status_mask) { 867 - if (++ignored > 100) 868 - goto out; 838 + if (rx & sport->port.ignore_status_mask) 869 839 continue; 870 - } 871 840 872 841 rx &= (sport->port.read_status_mask | 0xFF); 873 842 ··· 878 853 flg = TTY_OVERRUN; 879 854 880 855 sport->port.sysrq = 0; 856 + } else if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx)) { 857 + continue; 881 858 } 882 859 883 860 if (sport->port.ignore_status_mask & URXD_DUMMY_READ) 884 - goto out; 861 + continue; 885 862 886 863 if (tty_insert_flip_char(port, rx, flg) == 0) 887 864 sport->port.icount.buf_overrun++; 888 865 } 889 866 890 - out: 891 867 tty_flip_buffer_push(port); 892 868 893 869 return IRQ_HANDLED; ··· 1173 1147 status = dmaengine_tx_status(chan, sport->rx_cookie, &state); 1174 1148 1175 1149 if (status == DMA_ERROR) { 1150 + spin_lock(&sport->port.lock); 1176 1151 imx_uart_clear_rx_errors(sport); 1152 + spin_unlock(&sport->port.lock); 1177 1153 return; 1178 1154 } 1179 1155 1180 - if (!(sport->port.ignore_status_mask & URXD_DUMMY_READ)) { 1156 + /* 1157 + * The state-residue variable represents the empty space 1158 + * relative to the entire buffer. Taking this in consideration 1159 + * the head is always calculated base on the buffer total 1160 + * length - DMA transaction residue. The UART script from the 1161 + * SDMA firmware will jump to the next buffer descriptor, 1162 + * once a DMA transaction if finalized (IMX53 RM - A.4.1.2.4). 1163 + * Taking this in consideration the tail is always at the 1164 + * beginning of the buffer descriptor that contains the head. 1165 + */ 1181 1166 1182 - /* 1183 - * The state-residue variable represents the empty space 1184 - * relative to the entire buffer. Taking this in consideration 1185 - * the head is always calculated base on the buffer total 1186 - * length - DMA transaction residue. The UART script from the 1187 - * SDMA firmware will jump to the next buffer descriptor, 1188 - * once a DMA transaction if finalized (IMX53 RM - A.4.1.2.4). 1189 - * Taking this in consideration the tail is always at the 1190 - * beginning of the buffer descriptor that contains the head. 1191 - */ 1167 + /* Calculate the head */ 1168 + rx_ring->head = sg_dma_len(sgl) - state.residue; 1192 1169 1193 - /* Calculate the head */ 1194 - rx_ring->head = sg_dma_len(sgl) - state.residue; 1170 + /* Calculate the tail. */ 1171 + bd_size = sg_dma_len(sgl) / sport->rx_periods; 1172 + rx_ring->tail = ((rx_ring->head-1) / bd_size) * bd_size; 1195 1173 1196 - /* Calculate the tail. */ 1197 - bd_size = sg_dma_len(sgl) / sport->rx_periods; 1198 - rx_ring->tail = ((rx_ring->head-1) / bd_size) * bd_size; 1174 + if (rx_ring->head <= sg_dma_len(sgl) && 1175 + rx_ring->head > rx_ring->tail) { 1199 1176 1200 - if (rx_ring->head <= sg_dma_len(sgl) && 1201 - rx_ring->head > rx_ring->tail) { 1177 + /* Move data from tail to head */ 1178 + r_bytes = rx_ring->head - rx_ring->tail; 1202 1179 1203 - /* Move data from tail to head */ 1204 - r_bytes = rx_ring->head - rx_ring->tail; 1180 + /* If we received something, check for 0xff flood */ 1181 + spin_lock(&sport->port.lock); 1182 + imx_uart_check_flood(sport, imx_uart_readl(sport, USR2)); 1183 + spin_unlock(&sport->port.lock); 1184 + 1185 + if (!(sport->port.ignore_status_mask & URXD_DUMMY_READ)) { 1205 1186 1206 1187 /* CPU claims ownership of RX DMA buffer */ 1207 1188 dma_sync_sg_for_cpu(sport->port.dev, sgl, 1, 1208 - DMA_FROM_DEVICE); 1189 + DMA_FROM_DEVICE); 1209 1190 1210 1191 w_bytes = tty_insert_flip_string(port, 1211 - sport->rx_buf + rx_ring->tail, r_bytes); 1192 + sport->rx_buf + rx_ring->tail, r_bytes); 1212 1193 1213 1194 /* UART retrieves ownership of RX DMA buffer */ 1214 1195 dma_sync_sg_for_device(sport->port.dev, sgl, 1, 1215 - DMA_FROM_DEVICE); 1196 + DMA_FROM_DEVICE); 1216 1197 1217 1198 if (w_bytes != r_bytes) 1218 1199 sport->port.icount.buf_overrun++; 1219 1200 1220 1201 sport->port.icount.rx += w_bytes; 1221 - } else { 1222 - WARN_ON(rx_ring->head > sg_dma_len(sgl)); 1223 - WARN_ON(rx_ring->head <= rx_ring->tail); 1224 1202 } 1203 + } else { 1204 + WARN_ON(rx_ring->head > sg_dma_len(sgl)); 1205 + WARN_ON(rx_ring->head <= rx_ring->tail); 1225 1206 } 1226 1207 1227 1208 if (w_bytes) { ··· 1303 1270 sport->port.icount.overrun++; 1304 1271 imx_uart_writel(sport, USR2_ORE, USR2); 1305 1272 } 1273 + 1274 + sport->idle_counter = 0; 1306 1275 1307 1276 } 1308 1277 ··· 1433 1398 static int imx_uart_startup(struct uart_port *port) 1434 1399 { 1435 1400 struct imx_port *sport = (struct imx_port *)port; 1436 - int retval, i; 1401 + int retval; 1437 1402 unsigned long flags; 1438 1403 int dma_is_inited = 0; 1439 1404 u32 ucr1, ucr2, ucr3, ucr4, uts; ··· 1465 1430 dma_is_inited = 1; 1466 1431 1467 1432 spin_lock_irqsave(&sport->port.lock, flags); 1433 + 1468 1434 /* Reset fifo's and state machines */ 1469 - i = 100; 1470 - 1471 - ucr2 = imx_uart_readl(sport, UCR2); 1472 - ucr2 &= ~UCR2_SRST; 1473 - imx_uart_writel(sport, ucr2, UCR2); 1474 - 1475 - while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) 1476 - udelay(1); 1435 + imx_uart_soft_reset(sport); 1477 1436 1478 1437 /* 1479 1438 * Finally, clear and enable interrupts ··· 1593 1564 spin_lock_irqsave(&sport->port.lock, flags); 1594 1565 1595 1566 ucr1 = imx_uart_readl(sport, UCR1); 1596 - ucr1 &= ~(UCR1_TRDYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_RXDMAEN | UCR1_ATDMAEN); 1567 + ucr1 &= ~(UCR1_TRDYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_RXDMAEN | 1568 + UCR1_ATDMAEN | UCR1_SNDBRK); 1597 1569 /* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ 1598 1570 if (port->rs485.flags & SER_RS485_ENABLED && 1599 1571 port->rs485.flags & SER_RS485_RTS_ON_SEND && ··· 1623 1593 { 1624 1594 struct imx_port *sport = (struct imx_port *)port; 1625 1595 struct scatterlist *sgl = &sport->tx_sgl[0]; 1626 - u32 ucr2; 1627 - int i = 100, ubir, ubmr, uts; 1628 1596 1629 1597 if (!sport->dma_chan_tx) 1630 1598 return; ··· 1640 1612 sport->dma_is_txing = 0; 1641 1613 } 1642 1614 1643 - /* 1644 - * According to the Reference Manual description of the UART SRST bit: 1645 - * 1646 - * "Reset the transmit and receive state machines, 1647 - * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD 1648 - * and UTS[6-3]". 1649 - * 1650 - * We don't need to restore the old values from USR1, USR2, URXD and 1651 - * UTXD. UBRC is read only, so only save/restore the other three 1652 - * registers. 1653 - */ 1654 - ubir = imx_uart_readl(sport, UBIR); 1655 - ubmr = imx_uart_readl(sport, UBMR); 1656 - uts = imx_uart_readl(sport, IMX21_UTS); 1615 + imx_uart_soft_reset(sport); 1657 1616 1658 - ucr2 = imx_uart_readl(sport, UCR2); 1659 - ucr2 &= ~UCR2_SRST; 1660 - imx_uart_writel(sport, ucr2, UCR2); 1661 - 1662 - while (!(imx_uart_readl(sport, UCR2) & UCR2_SRST) && (--i > 0)) 1663 - udelay(1); 1664 - 1665 - /* Restore the registers */ 1666 - imx_uart_writel(sport, ubir, UBIR); 1667 - imx_uart_writel(sport, ubmr, UBMR); 1668 - imx_uart_writel(sport, uts, IMX21_UTS); 1669 1617 } 1670 1618 1671 1619 static void ··· 1958 1954 if (!(rs485conf->flags & SER_RS485_ENABLED) || 1959 1955 rs485conf->flags & SER_RS485_RX_DURING_TX) 1960 1956 imx_uart_start_rx(port); 1957 + 1958 + if (port->rs485_rx_during_tx_gpio) 1959 + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1960 + !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); 1961 1961 1962 1962 return 0; 1963 1963 } ··· 2348 2340 return ret; 2349 2341 } 2350 2342 2351 - /* initialize shadow register values */ 2352 - sport->ucr1 = readl(sport->port.membase + UCR1); 2353 - sport->ucr2 = readl(sport->port.membase + UCR2); 2354 - sport->ucr3 = readl(sport->port.membase + UCR3); 2355 - sport->ucr4 = readl(sport->port.membase + UCR4); 2356 - sport->ufcr = readl(sport->port.membase + UFCR); 2357 - 2358 2343 ret = uart_get_rs485_mode(&sport->port); 2359 2344 if (ret) { 2360 2345 clk_disable_unprepare(sport->clk_ipg); ··· 2374 2373 ucr1 = imx_uart_readl(sport, UCR1); 2375 2374 ucr1 &= ~(UCR1_ADEN | UCR1_TRDYEN | UCR1_IDEN | UCR1_RRDYEN | UCR1_RTSDEN); 2376 2375 imx_uart_writel(sport, ucr1, UCR1); 2376 + 2377 + /* Disable Ageing Timer interrupt */ 2378 + ucr2 = imx_uart_readl(sport, UCR2); 2379 + ucr2 &= ~UCR2_ATEN; 2380 + imx_uart_writel(sport, ucr2, UCR2); 2377 2381 2378 2382 /* 2379 2383 * In case RS485 is enabled without GPIO RTS control, the UART IP
+144 -101
drivers/tty/serial/liteuart.c
··· 5 5 * Copyright (C) 2019-2020 Antmicro <www.antmicro.com> 6 6 */ 7 7 8 + #include <linux/bits.h> 8 9 #include <linux/console.h> 10 + #include <linux/interrupt.h> 9 11 #include <linux/litex.h> 10 12 #include <linux/module.h> 11 13 #include <linux/of.h> ··· 40 38 #define OFF_EV_ENABLE 0x14 41 39 42 40 /* events */ 43 - #define EV_TX 0x1 44 - #define EV_RX 0x2 41 + #define EV_TX BIT(0) 42 + #define EV_RX BIT(1) 45 43 46 44 struct liteuart_port { 47 45 struct uart_port port; 48 46 struct timer_list timer; 49 - u32 id; 47 + u8 irq_reg; 50 48 }; 51 49 52 50 #define to_liteuart_port(port) container_of(port, struct liteuart_port, port) ··· 59 57 60 58 static struct uart_driver liteuart_driver = { 61 59 .owner = THIS_MODULE, 62 - .driver_name = "liteuart", 60 + .driver_name = KBUILD_MODNAME, 63 61 .dev_name = "ttyLXU", 64 62 .major = 0, 65 63 .minor = 0, ··· 69 67 #endif 70 68 }; 71 69 72 - static void liteuart_timer(struct timer_list *t) 70 + static void liteuart_update_irq_reg(struct uart_port *port, bool set, u8 mask) 73 71 { 74 - struct liteuart_port *uart = from_timer(uart, t, timer); 75 - struct uart_port *port = &uart->port; 76 - unsigned char __iomem *membase = port->membase; 77 - unsigned int flg = TTY_NORMAL; 78 - int ch; 79 - unsigned long status; 72 + struct liteuart_port *uart = to_liteuart_port(port); 80 73 81 - while ((status = !litex_read8(membase + OFF_RXEMPTY)) == 1) { 74 + if (set) 75 + uart->irq_reg |= mask; 76 + else 77 + uart->irq_reg &= ~mask; 78 + 79 + if (port->irq) 80 + litex_write8(port->membase + OFF_EV_ENABLE, uart->irq_reg); 81 + } 82 + 83 + static void liteuart_stop_tx(struct uart_port *port) 84 + { 85 + liteuart_update_irq_reg(port, false, EV_TX); 86 + } 87 + 88 + static void liteuart_start_tx(struct uart_port *port) 89 + { 90 + liteuart_update_irq_reg(port, true, EV_TX); 91 + } 92 + 93 + static void liteuart_stop_rx(struct uart_port *port) 94 + { 95 + struct liteuart_port *uart = to_liteuart_port(port); 96 + 97 + /* just delete timer */ 98 + del_timer(&uart->timer); 99 + } 100 + 101 + static void liteuart_rx_chars(struct uart_port *port) 102 + { 103 + unsigned char __iomem *membase = port->membase; 104 + u8 ch; 105 + 106 + while (!litex_read8(membase + OFF_RXEMPTY)) { 82 107 ch = litex_read8(membase + OFF_RXTX); 83 108 port->icount.rx++; 84 109 85 110 /* necessary for RXEMPTY to refresh its value */ 86 - litex_write8(membase + OFF_EV_PENDING, EV_TX | EV_RX); 111 + litex_write8(membase + OFF_EV_PENDING, EV_RX); 87 112 88 113 /* no overflow bits in status */ 89 114 if (!(uart_handle_sysrq_char(port, ch))) 90 - uart_insert_char(port, status, 0, ch, flg); 91 - 92 - tty_flip_buffer_push(&port->state->port); 115 + uart_insert_char(port, 1, 0, ch, TTY_NORMAL); 93 116 } 94 117 95 - mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); 118 + tty_flip_buffer_push(&port->state->port); 96 119 } 97 120 98 - static void liteuart_putchar(struct uart_port *port, unsigned char ch) 121 + static void liteuart_tx_chars(struct uart_port *port) 99 122 { 100 - while (litex_read8(port->membase + OFF_TXFULL)) 101 - cpu_relax(); 123 + u8 ch; 102 124 103 - litex_write8(port->membase + OFF_RXTX, ch); 125 + uart_port_tx(port, ch, 126 + !litex_read8(port->membase + OFF_TXFULL), 127 + litex_write8(port->membase + OFF_RXTX, ch)); 128 + } 129 + 130 + static irqreturn_t liteuart_interrupt(int irq, void *data) 131 + { 132 + struct liteuart_port *uart = data; 133 + struct uart_port *port = &uart->port; 134 + unsigned long flags; 135 + u8 isr; 136 + 137 + /* 138 + * if polling, the context would be "in_serving_softirq", so use 139 + * irq[save|restore] spin_lock variants to cover all possibilities 140 + */ 141 + spin_lock_irqsave(&port->lock, flags); 142 + isr = litex_read8(port->membase + OFF_EV_PENDING) & uart->irq_reg; 143 + if (isr & EV_RX) 144 + liteuart_rx_chars(port); 145 + if (isr & EV_TX) 146 + liteuart_tx_chars(port); 147 + spin_unlock_irqrestore(&port->lock, flags); 148 + 149 + return IRQ_RETVAL(isr); 150 + } 151 + 152 + static void liteuart_timer(struct timer_list *t) 153 + { 154 + struct liteuart_port *uart = from_timer(uart, t, timer); 155 + struct uart_port *port = &uart->port; 156 + 157 + liteuart_interrupt(0, port); 158 + mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); 104 159 } 105 160 106 161 static unsigned int liteuart_tx_empty(struct uart_port *port) ··· 179 120 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; 180 121 } 181 122 182 - static void liteuart_stop_tx(struct uart_port *port) 183 - { 184 - } 185 - 186 - static void liteuart_start_tx(struct uart_port *port) 187 - { 188 - struct circ_buf *xmit = &port->state->xmit; 189 - unsigned char ch; 190 - 191 - if (unlikely(port->x_char)) { 192 - litex_write8(port->membase + OFF_RXTX, port->x_char); 193 - port->icount.tx++; 194 - port->x_char = 0; 195 - } else if (!uart_circ_empty(xmit)) { 196 - while (xmit->head != xmit->tail) { 197 - ch = xmit->buf[xmit->tail]; 198 - uart_xmit_advance(port, 1); 199 - liteuart_putchar(port, ch); 200 - } 201 - } 202 - 203 - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 204 - uart_write_wakeup(port); 205 - } 206 - 207 - static void liteuart_stop_rx(struct uart_port *port) 208 - { 209 - struct liteuart_port *uart = to_liteuart_port(port); 210 - 211 - /* just delete timer */ 212 - del_timer(&uart->timer); 213 - } 214 - 215 - static void liteuart_break_ctl(struct uart_port *port, int break_state) 216 - { 217 - /* LiteUART doesn't support sending break signal */ 218 - } 219 - 220 123 static int liteuart_startup(struct uart_port *port) 221 124 { 222 125 struct liteuart_port *uart = to_liteuart_port(port); 126 + unsigned long flags; 127 + int ret; 223 128 224 - /* disable events */ 225 - litex_write8(port->membase + OFF_EV_ENABLE, 0); 129 + if (port->irq) { 130 + ret = request_irq(port->irq, liteuart_interrupt, 0, 131 + KBUILD_MODNAME, uart); 132 + if (ret) { 133 + dev_warn(port->dev, 134 + "line %d irq %d failed: switch to polling\n", 135 + port->line, port->irq); 136 + port->irq = 0; 137 + } 138 + } 226 139 227 - /* prepare timer for polling */ 228 - timer_setup(&uart->timer, liteuart_timer, 0); 229 - mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); 140 + spin_lock_irqsave(&port->lock, flags); 141 + /* only enabling rx irqs during startup */ 142 + liteuart_update_irq_reg(port, true, EV_RX); 143 + spin_unlock_irqrestore(&port->lock, flags); 144 + 145 + if (!port->irq) { 146 + timer_setup(&uart->timer, liteuart_timer, 0); 147 + mod_timer(&uart->timer, jiffies + uart_poll_timeout(port)); 148 + } 230 149 231 150 return 0; 232 151 } 233 152 234 153 static void liteuart_shutdown(struct uart_port *port) 235 154 { 155 + struct liteuart_port *uart = to_liteuart_port(port); 156 + unsigned long flags; 157 + 158 + spin_lock_irqsave(&port->lock, flags); 159 + liteuart_update_irq_reg(port, false, EV_RX | EV_TX); 160 + spin_unlock_irqrestore(&port->lock, flags); 161 + 162 + if (port->irq) 163 + free_irq(port->irq, port); 164 + else 165 + del_timer_sync(&uart->timer); 236 166 } 237 167 238 168 static void liteuart_set_termios(struct uart_port *port, struct ktermios *new, ··· 242 194 static const char *liteuart_type(struct uart_port *port) 243 195 { 244 196 return "liteuart"; 245 - } 246 - 247 - static void liteuart_release_port(struct uart_port *port) 248 - { 249 - } 250 - 251 - static int liteuart_request_port(struct uart_port *port) 252 - { 253 - return 0; 254 197 } 255 198 256 199 static void liteuart_config_port(struct uart_port *port, int flags) ··· 270 231 .stop_tx = liteuart_stop_tx, 271 232 .start_tx = liteuart_start_tx, 272 233 .stop_rx = liteuart_stop_rx, 273 - .break_ctl = liteuart_break_ctl, 274 234 .startup = liteuart_startup, 275 235 .shutdown = liteuart_shutdown, 276 236 .set_termios = liteuart_set_termios, 277 237 .type = liteuart_type, 278 - .release_port = liteuart_release_port, 279 - .request_port = liteuart_request_port, 280 238 .config_port = liteuart_config_port, 281 239 .verify_port = liteuart_verify_port, 282 240 }; ··· 285 249 struct xa_limit limit; 286 250 int dev_id, ret; 287 251 252 + uart = devm_kzalloc(&pdev->dev, sizeof(struct liteuart_port), GFP_KERNEL); 253 + if (!uart) 254 + return -ENOMEM; 255 + 256 + port = &uart->port; 257 + 258 + /* get membase */ 259 + port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 260 + if (IS_ERR(port->membase)) 261 + return PTR_ERR(port->membase); 262 + 263 + ret = platform_get_irq_optional(pdev, 0); 264 + if (ret < 0 && ret != -ENXIO) 265 + return ret; 266 + if (ret > 0) 267 + port->irq = ret; 268 + 288 269 /* look for aliases; auto-enumerate for free index if not found */ 289 270 dev_id = of_alias_get_id(pdev->dev.of_node, "serial"); 290 271 if (dev_id < 0) ··· 309 256 else 310 257 limit = XA_LIMIT(dev_id, dev_id); 311 258 312 - uart = devm_kzalloc(&pdev->dev, sizeof(struct liteuart_port), GFP_KERNEL); 313 - if (!uart) 314 - return -ENOMEM; 315 - 316 259 ret = xa_alloc(&liteuart_array, &dev_id, uart, limit, GFP_KERNEL); 317 260 if (ret) 318 261 return ret; 319 - 320 - uart->id = dev_id; 321 - port = &uart->port; 322 - 323 - /* get membase */ 324 - port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 325 - if (IS_ERR(port->membase)) { 326 - ret = PTR_ERR(port->membase); 327 - goto err_erase_id; 328 - } 329 262 330 263 /* values not from device tree */ 331 264 port->dev = &pdev->dev; 332 265 port->iotype = UPIO_MEM; 333 266 port->flags = UPF_BOOT_AUTOCONF; 334 267 port->ops = &liteuart_ops; 335 - port->regshift = 2; 336 268 port->fifosize = 16; 337 - port->iobase = 1; 338 269 port->type = PORT_UNKNOWN; 339 270 port->line = dev_id; 340 271 spin_lock_init(&port->lock); ··· 332 295 return 0; 333 296 334 297 err_erase_id: 335 - xa_erase(&liteuart_array, uart->id); 298 + xa_erase(&liteuart_array, dev_id); 336 299 337 300 return ret; 338 301 } ··· 340 303 static int liteuart_remove(struct platform_device *pdev) 341 304 { 342 305 struct uart_port *port = platform_get_drvdata(pdev); 343 - struct liteuart_port *uart = to_liteuart_port(port); 306 + unsigned int line = port->line; 344 307 345 308 uart_remove_one_port(&liteuart_driver, port); 346 - xa_erase(&liteuart_array, uart->id); 309 + xa_erase(&liteuart_array, line); 347 310 348 311 return 0; 349 312 } ··· 358 321 .probe = liteuart_probe, 359 322 .remove = liteuart_remove, 360 323 .driver = { 361 - .name = "liteuart", 324 + .name = KBUILD_MODNAME, 362 325 .of_match_table = liteuart_of_match, 363 326 }, 364 327 }; 365 328 366 329 #ifdef CONFIG_SERIAL_LITEUART_CONSOLE 330 + 331 + static void liteuart_putchar(struct uart_port *port, unsigned char ch) 332 + { 333 + while (litex_read8(port->membase + OFF_TXFULL)) 334 + cpu_relax(); 335 + 336 + litex_write8(port->membase + OFF_RXTX, ch); 337 + } 367 338 368 339 static void liteuart_console_write(struct console *co, const char *s, 369 340 unsigned int count) ··· 412 367 } 413 368 414 369 static struct console liteuart_console = { 415 - .name = "liteuart", 370 + .name = KBUILD_MODNAME, 416 371 .write = liteuart_console_write, 417 372 .device = uart_console_device, 418 373 .setup = liteuart_console_setup, ··· 460 415 return res; 461 416 462 417 res = platform_driver_register(&liteuart_platform_driver); 463 - if (res) { 418 + if (res) 464 419 uart_unregister_driver(&liteuart_driver); 465 - return res; 466 - } 467 420 468 - return 0; 421 + return res; 469 422 } 470 423 471 424 static void __exit liteuart_exit(void)
+1 -1
drivers/tty/serial/max3100.c
··· 247 247 cts = (rx & MAX3100_CTS) > 0; 248 248 if (s->cts != cts) { 249 249 s->cts = cts; 250 - uart_handle_cts_change(&s->port, cts ? TIOCM_CTS : 0); 250 + uart_handle_cts_change(&s->port, cts); 251 251 } 252 252 253 253 return ret;
+1 -2
drivers/tty/serial/max310x.c
··· 819 819 820 820 if (ists & MAX310X_IRQ_CTS_BIT) { 821 821 lsr = max310x_port_read(port, MAX310X_LSR_IRQSTS_REG); 822 - uart_handle_cts_change(port, 823 - !!(lsr & MAX310X_LSR_CTS_BIT)); 822 + uart_handle_cts_change(port, lsr & MAX310X_LSR_CTS_BIT); 824 823 } 825 824 if (rxlen) 826 825 max310x_handle_rx(port, rxlen);
+1
drivers/tty/serial/msm_serial.c
··· 1120 1120 1121 1121 static int msm_set_baud_rate(struct uart_port *port, unsigned int baud, 1122 1122 unsigned long *saved_flags) 1123 + __must_hold(&port->lock) 1123 1124 { 1124 1125 unsigned int rxstale, watermark, mask; 1125 1126 struct msm_port *msm_port = to_msm_port(port);
+1 -1
drivers/tty/serial/pch_uart.c
··· 1775 1775 char name[32]; 1776 1776 1777 1777 snprintf(name, sizeof(name), "uart%d_regs", priv->port.line); 1778 - debugfs_remove(debugfs_lookup(name, NULL)); 1778 + debugfs_lookup_and_remove(name, NULL); 1779 1779 uart_remove_one_port(&pch_uart_driver, &priv->port); 1780 1780 free_page((unsigned long)priv->rxbuf.buf); 1781 1781 }
+2
drivers/tty/serial/pic32_uart.c
··· 889 889 sport->irq_rx = irq_of_parse_and_map(np, 1); 890 890 sport->irq_tx = irq_of_parse_and_map(np, 2); 891 891 sport->clk = devm_clk_get(&pdev->dev, NULL); 892 + if (IS_ERR(sport->clk)) 893 + return PTR_ERR(sport->clk); 892 894 sport->dev = &pdev->dev; 893 895 894 896 /* Hardware flow control: gpios
+434 -240
drivers/tty/serial/qcom_geni_serial.c
··· 16 16 #include <linux/platform_device.h> 17 17 #include <linux/pm_runtime.h> 18 18 #include <linux/pm_wakeirq.h> 19 - #include <linux/qcom-geni-se.h> 19 + #include <linux/soc/qcom/geni-se.h> 20 20 #include <linux/serial.h> 21 21 #include <linux/serial_core.h> 22 22 #include <linux/slab.h> ··· 39 39 #define SE_UART_MANUAL_RFR 0x2ac 40 40 41 41 /* SE_UART_TRANS_CFG */ 42 - #define UART_TX_PAR_EN BIT(0) 43 - #define UART_CTS_MASK BIT(1) 44 - 45 - /* SE_UART_TX_WORD_LEN */ 46 - #define TX_WORD_LEN_MSK GENMASK(9, 0) 42 + #define UART_TX_PAR_EN BIT(0) 43 + #define UART_CTS_MASK BIT(1) 47 44 48 45 /* SE_UART_TX_STOP_BIT_LEN */ 49 - #define TX_STOP_BIT_LEN_MSK GENMASK(23, 0) 50 - #define TX_STOP_BIT_LEN_1 0 51 - #define TX_STOP_BIT_LEN_1_5 1 52 - #define TX_STOP_BIT_LEN_2 2 53 - 54 - /* SE_UART_TX_TRANS_LEN */ 55 - #define TX_TRANS_LEN_MSK GENMASK(23, 0) 46 + #define TX_STOP_BIT_LEN_1 0 47 + #define TX_STOP_BIT_LEN_2 2 56 48 57 49 /* SE_UART_RX_TRANS_CFG */ 58 - #define UART_RX_INS_STATUS_BIT BIT(2) 59 - #define UART_RX_PAR_EN BIT(3) 50 + #define UART_RX_PAR_EN BIT(3) 60 51 61 52 /* SE_UART_RX_WORD_LEN */ 62 - #define RX_WORD_LEN_MASK GENMASK(9, 0) 53 + #define RX_WORD_LEN_MASK GENMASK(9, 0) 63 54 64 55 /* SE_UART_RX_STALE_CNT */ 65 - #define RX_STALE_CNT GENMASK(23, 0) 56 + #define RX_STALE_CNT GENMASK(23, 0) 66 57 67 58 /* SE_UART_TX_PARITY_CFG/RX_PARITY_CFG */ 68 - #define PAR_CALC_EN BIT(0) 69 - #define PAR_MODE_MSK GENMASK(2, 1) 70 - #define PAR_MODE_SHFT 1 71 - #define PAR_EVEN 0x00 72 - #define PAR_ODD 0x01 73 - #define PAR_SPACE 0x10 74 - #define PAR_MARK 0x11 59 + #define PAR_CALC_EN BIT(0) 60 + #define PAR_EVEN 0x00 61 + #define PAR_ODD 0x01 62 + #define PAR_SPACE 0x10 75 63 76 64 /* SE_UART_MANUAL_RFR register fields */ 77 - #define UART_MANUAL_RFR_EN BIT(31) 78 - #define UART_RFR_NOT_READY BIT(1) 79 - #define UART_RFR_READY BIT(0) 65 + #define UART_MANUAL_RFR_EN BIT(31) 66 + #define UART_RFR_NOT_READY BIT(1) 67 + #define UART_RFR_READY BIT(0) 80 68 81 69 /* UART M_CMD OP codes */ 82 - #define UART_START_TX 0x1 83 - #define UART_START_BREAK 0x4 84 - #define UART_STOP_BREAK 0x5 70 + #define UART_START_TX 0x1 85 71 /* UART S_CMD OP codes */ 86 - #define UART_START_READ 0x1 87 - #define UART_PARAM 0x1 72 + #define UART_START_READ 0x1 73 + #define UART_PARAM 0x1 74 + #define UART_PARAM_RFR_OPEN BIT(7) 88 75 89 - #define UART_OVERSAMPLING 32 90 - #define STALE_TIMEOUT 16 91 - #define DEFAULT_BITS_PER_CHAR 10 92 - #define GENI_UART_CONS_PORTS 1 93 - #define GENI_UART_PORTS 3 94 - #define DEF_FIFO_DEPTH_WORDS 16 95 - #define DEF_TX_WM 2 96 - #define DEF_FIFO_WIDTH_BITS 32 97 - #define UART_RX_WM 2 76 + #define UART_OVERSAMPLING 32 77 + #define STALE_TIMEOUT 16 78 + #define DEFAULT_BITS_PER_CHAR 10 79 + #define GENI_UART_CONS_PORTS 1 80 + #define GENI_UART_PORTS 3 81 + #define DEF_FIFO_DEPTH_WORDS 16 82 + #define DEF_TX_WM 2 83 + #define DEF_FIFO_WIDTH_BITS 32 84 + #define UART_RX_WM 2 98 85 99 86 /* SE_UART_LOOPBACK_CFG */ 100 - #define RX_TX_SORTED BIT(0) 101 - #define CTS_RTS_SORTED BIT(1) 102 - #define RX_TX_CTS_RTS_SORTED (RX_TX_SORTED | CTS_RTS_SORTED) 87 + #define RX_TX_SORTED BIT(0) 88 + #define CTS_RTS_SORTED BIT(1) 89 + #define RX_TX_CTS_RTS_SORTED (RX_TX_SORTED | CTS_RTS_SORTED) 103 90 104 91 /* UART pin swap value */ 105 - #define DEFAULT_IO_MACRO_IO0_IO1_MASK GENMASK(3, 0) 92 + #define DEFAULT_IO_MACRO_IO0_IO1_MASK GENMASK(3, 0) 106 93 #define IO_MACRO_IO0_SEL 0x3 107 - #define DEFAULT_IO_MACRO_IO2_IO3_MASK GENMASK(15, 4) 94 + #define DEFAULT_IO_MACRO_IO2_IO3_MASK GENMASK(15, 4) 108 95 #define IO_MACRO_IO2_IO3_SWAP 0x4640 109 96 110 97 /* We always configure 4 bytes per FIFO word */ 111 - #define BYTES_PER_FIFO_WORD 4 98 + #define BYTES_PER_FIFO_WORD 4U 99 + 100 + #define DMA_RX_BUF_SIZE 2048 101 + 102 + struct qcom_geni_device_data { 103 + bool console; 104 + enum geni_se_xfer_mode mode; 105 + }; 112 106 113 107 struct qcom_geni_private_data { 114 108 /* NOTE: earlycon port will have NULL here */ ··· 122 128 u32 tx_fifo_depth; 123 129 u32 tx_fifo_width; 124 130 u32 rx_fifo_depth; 131 + dma_addr_t tx_dma_addr; 132 + dma_addr_t rx_dma_addr; 125 133 bool setup; 126 - int (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop); 127 134 unsigned int baud; 128 - void *rx_fifo; 135 + void *rx_buf; 129 136 u32 loopback; 130 137 bool brk; 131 138 ··· 136 141 bool cts_rts_swap; 137 142 138 143 struct qcom_geni_private_data private_data; 144 + const struct qcom_geni_device_data *dev_data; 139 145 }; 140 146 141 147 static const struct uart_ops qcom_geni_console_pops; 142 148 static const struct uart_ops qcom_geni_uart_pops; 143 149 static struct uart_driver qcom_geni_console_driver; 144 150 static struct uart_driver qcom_geni_uart_driver; 145 - static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop); 146 - static int handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop); 147 - static unsigned int qcom_geni_serial_tx_empty(struct uart_port *port); 148 - static void qcom_geni_serial_stop_rx(struct uart_port *uport); 149 - static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop); 150 151 151 - #define to_dev_port(ptr, member) \ 152 - container_of(ptr, struct qcom_geni_serial_port, member) 152 + static inline struct qcom_geni_serial_port *to_dev_port(struct uart_port *uport) 153 + { 154 + return container_of(uport, struct qcom_geni_serial_port, uport); 155 + } 153 156 154 157 static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS] = { 155 158 [0] = { 156 159 .uport = { 157 - .iotype = UPIO_MEM, 158 - .ops = &qcom_geni_uart_pops, 159 - .flags = UPF_BOOT_AUTOCONF, 160 - .line = 0, 160 + .iotype = UPIO_MEM, 161 + .ops = &qcom_geni_uart_pops, 162 + .flags = UPF_BOOT_AUTOCONF, 163 + .line = 0, 161 164 }, 162 165 }, 163 166 [1] = { 164 167 .uport = { 165 - .iotype = UPIO_MEM, 166 - .ops = &qcom_geni_uart_pops, 167 - .flags = UPF_BOOT_AUTOCONF, 168 - .line = 1, 168 + .iotype = UPIO_MEM, 169 + .ops = &qcom_geni_uart_pops, 170 + .flags = UPF_BOOT_AUTOCONF, 171 + .line = 1, 169 172 }, 170 173 }, 171 174 [2] = { 172 175 .uport = { 173 - .iotype = UPIO_MEM, 174 - .ops = &qcom_geni_uart_pops, 175 - .flags = UPF_BOOT_AUTOCONF, 176 - .line = 2, 176 + .iotype = UPIO_MEM, 177 + .ops = &qcom_geni_uart_pops, 178 + .flags = UPF_BOOT_AUTOCONF, 179 + .line = 2, 177 180 }, 178 181 }, 179 182 }; ··· 188 195 static int qcom_geni_serial_request_port(struct uart_port *uport) 189 196 { 190 197 struct platform_device *pdev = to_platform_device(uport->dev); 191 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 198 + struct qcom_geni_serial_port *port = to_dev_port(uport); 192 199 193 200 uport->membase = devm_platform_ioremap_resource(pdev, 0); 194 201 if (IS_ERR(uport->membase)) ··· 225 232 unsigned int mctrl) 226 233 { 227 234 u32 uart_manual_rfr = 0; 228 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 235 + struct qcom_geni_serial_port *port = to_dev_port(uport); 229 236 230 237 if (uart_console(uport)) 231 238 return; ··· 255 262 return port; 256 263 } 257 264 265 + static bool qcom_geni_serial_main_active(struct uart_port *uport) 266 + { 267 + return readl(uport->membase + SE_GENI_STATUS) & M_GENI_CMD_ACTIVE; 268 + } 269 + 270 + static bool qcom_geni_serial_secondary_active(struct uart_port *uport) 271 + { 272 + return readl(uport->membase + SE_GENI_STATUS) & S_GENI_CMD_ACTIVE; 273 + } 274 + 258 275 static bool qcom_geni_serial_poll_bit(struct uart_port *uport, 259 276 int offset, int field, bool set) 260 277 { ··· 276 273 struct qcom_geni_private_data *private_data = uport->private_data; 277 274 278 275 if (private_data->drv) { 279 - port = to_dev_port(uport, uport); 276 + port = to_dev_port(uport); 280 277 baud = port->baud; 281 278 if (!baud) 282 279 baud = 115200; ··· 341 338 } 342 339 343 340 #ifdef CONFIG_CONSOLE_POLL 344 - 345 341 static int qcom_geni_serial_get_char(struct uart_port *uport) 346 342 { 347 343 struct qcom_geni_private_data *private_data = uport->private_data; ··· 523 521 spin_unlock_irqrestore(&uport->lock, flags); 524 522 } 525 523 526 - static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) 524 + static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) 527 525 { 528 526 u32 i; 529 527 unsigned char buf[sizeof(u32)]; 530 528 struct tty_port *tport; 531 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 529 + struct qcom_geni_serial_port *port = to_dev_port(uport); 532 530 533 531 tport = &uport->state->port; 534 532 for (i = 0; i < bytes; ) { ··· 558 556 } 559 557 if (!drop) 560 558 tty_flip_buffer_push(tport); 561 - return 0; 562 559 } 563 560 #else 564 - static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) 561 + static void handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) 565 562 { 566 - return -EPERM; 567 - } 568 563 564 + } 569 565 #endif /* CONFIG_SERIAL_QCOM_GENI_CONSOLE */ 570 566 571 - static int handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop) 567 + static void handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop) 572 568 { 573 - struct tty_port *tport; 574 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 575 - u32 num_bytes_pw = port->tx_fifo_width / BITS_PER_BYTE; 576 - u32 words = ALIGN(bytes, num_bytes_pw) / num_bytes_pw; 569 + struct qcom_geni_serial_port *port = to_dev_port(uport); 570 + struct tty_port *tport = &uport->state->port; 577 571 int ret; 578 572 579 - tport = &uport->state->port; 580 - ioread32_rep(uport->membase + SE_GENI_RX_FIFOn, port->rx_fifo, words); 581 - if (drop) 582 - return 0; 583 - 584 - ret = tty_insert_flip_string(tport, port->rx_fifo, bytes); 573 + ret = tty_insert_flip_string(tport, port->rx_buf, bytes); 585 574 if (ret != bytes) { 586 575 dev_err(uport->dev, "%s:Unable to push data ret %d_bytes %d\n", 587 576 __func__, ret, bytes); ··· 580 587 } 581 588 uport->icount.rx += ret; 582 589 tty_flip_buffer_push(tport); 583 - return ret; 584 590 } 585 591 586 - static void qcom_geni_serial_start_tx(struct uart_port *uport) 592 + static unsigned int qcom_geni_serial_tx_empty(struct uart_port *uport) 587 593 { 588 - u32 irq_en; 589 - u32 status; 594 + return !readl(uport->membase + SE_GENI_TX_FIFO_STATUS); 595 + } 590 596 591 - status = readl(uport->membase + SE_GENI_STATUS); 592 - if (status & M_GENI_CMD_ACTIVE) 597 + static void qcom_geni_serial_stop_tx_dma(struct uart_port *uport) 598 + { 599 + struct qcom_geni_serial_port *port = to_dev_port(uport); 600 + bool done; 601 + u32 m_irq_en; 602 + 603 + if (!qcom_geni_serial_main_active(uport)) 593 604 return; 594 605 595 - if (!qcom_geni_serial_tx_empty(uport)) 606 + if (port->rx_dma_addr) { 607 + geni_se_tx_dma_unprep(&port->se, port->tx_dma_addr, 608 + port->tx_remaining); 609 + port->tx_dma_addr = 0; 610 + port->tx_remaining = 0; 611 + } 612 + 613 + m_irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 614 + writel(m_irq_en, uport->membase + SE_GENI_M_IRQ_EN); 615 + geni_se_cancel_m_cmd(&port->se); 616 + 617 + done = qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS, 618 + S_CMD_CANCEL_EN, true); 619 + if (!done) { 620 + geni_se_abort_m_cmd(&port->se); 621 + done = qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, 622 + M_CMD_ABORT_EN, true); 623 + if (!done) 624 + dev_err_ratelimited(uport->dev, "M_CMD_ABORT_EN not set"); 625 + writel(M_CMD_ABORT_EN, uport->membase + SE_GENI_M_IRQ_CLEAR); 626 + } 627 + 628 + writel(M_CMD_CANCEL_EN, uport->membase + SE_GENI_M_IRQ_CLEAR); 629 + } 630 + 631 + static void qcom_geni_serial_start_tx_dma(struct uart_port *uport) 632 + { 633 + struct qcom_geni_serial_port *port = to_dev_port(uport); 634 + struct circ_buf *xmit = &uport->state->xmit; 635 + unsigned int xmit_size; 636 + int ret; 637 + 638 + if (port->tx_dma_addr) 639 + return; 640 + 641 + xmit_size = uart_circ_chars_pending(xmit); 642 + if (xmit_size < WAKEUP_CHARS) 643 + uart_write_wakeup(uport); 644 + 645 + xmit_size = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 646 + 647 + qcom_geni_serial_setup_tx(uport, xmit_size); 648 + 649 + ret = geni_se_tx_dma_prep(&port->se, &xmit->buf[xmit->tail], 650 + xmit_size, &port->tx_dma_addr); 651 + if (ret) { 652 + dev_err(uport->dev, "unable to start TX SE DMA: %d\n", ret); 653 + qcom_geni_serial_stop_tx_dma(uport); 654 + return; 655 + } 656 + 657 + port->tx_remaining = xmit_size; 658 + } 659 + 660 + static void qcom_geni_serial_start_tx_fifo(struct uart_port *uport) 661 + { 662 + u32 irq_en; 663 + 664 + if (qcom_geni_serial_main_active(uport) || 665 + !qcom_geni_serial_tx_empty(uport)) 596 666 return; 597 667 598 668 irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); ··· 665 609 writel(irq_en, uport->membase + SE_GENI_M_IRQ_EN); 666 610 } 667 611 668 - static void qcom_geni_serial_stop_tx(struct uart_port *uport) 612 + static void qcom_geni_serial_stop_tx_fifo(struct uart_port *uport) 669 613 { 670 614 u32 irq_en; 671 - u32 status; 672 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 615 + struct qcom_geni_serial_port *port = to_dev_port(uport); 673 616 674 617 irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 675 618 irq_en &= ~(M_CMD_DONE_EN | M_TX_FIFO_WATERMARK_EN); 676 619 writel(0, uport->membase + SE_GENI_TX_WATERMARK_REG); 677 620 writel(irq_en, uport->membase + SE_GENI_M_IRQ_EN); 678 - status = readl(uport->membase + SE_GENI_STATUS); 679 621 /* Possible stop tx is called multiple times. */ 680 - if (!(status & M_GENI_CMD_ACTIVE)) 622 + if (!qcom_geni_serial_main_active(uport)) 681 623 return; 682 624 683 625 geni_se_cancel_m_cmd(&port->se); ··· 689 635 writel(M_CMD_CANCEL_EN, uport->membase + SE_GENI_M_IRQ_CLEAR); 690 636 } 691 637 692 - static void qcom_geni_serial_start_rx(struct uart_port *uport) 693 - { 694 - u32 irq_en; 695 - u32 status; 696 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 697 - 698 - status = readl(uport->membase + SE_GENI_STATUS); 699 - if (status & S_GENI_CMD_ACTIVE) 700 - qcom_geni_serial_stop_rx(uport); 701 - 702 - geni_se_setup_s_cmd(&port->se, UART_START_READ, 0); 703 - 704 - irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN); 705 - irq_en |= S_RX_FIFO_WATERMARK_EN | S_RX_FIFO_LAST_EN; 706 - writel(irq_en, uport->membase + SE_GENI_S_IRQ_EN); 707 - 708 - irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 709 - irq_en |= M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN; 710 - writel(irq_en, uport->membase + SE_GENI_M_IRQ_EN); 711 - } 712 - 713 - static void qcom_geni_serial_stop_rx(struct uart_port *uport) 714 - { 715 - u32 irq_en; 716 - u32 status; 717 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 718 - u32 s_irq_status; 719 - 720 - irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN); 721 - irq_en &= ~(S_RX_FIFO_WATERMARK_EN | S_RX_FIFO_LAST_EN); 722 - writel(irq_en, uport->membase + SE_GENI_S_IRQ_EN); 723 - 724 - irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 725 - irq_en &= ~(M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN); 726 - writel(irq_en, uport->membase + SE_GENI_M_IRQ_EN); 727 - 728 - status = readl(uport->membase + SE_GENI_STATUS); 729 - /* Possible stop rx is called multiple times. */ 730 - if (!(status & S_GENI_CMD_ACTIVE)) 731 - return; 732 - 733 - geni_se_cancel_s_cmd(&port->se); 734 - qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS, 735 - S_CMD_CANCEL_EN, true); 736 - /* 737 - * If timeout occurs secondary engine remains active 738 - * and Abort sequence is executed. 739 - */ 740 - s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS); 741 - /* Flush the Rx buffer */ 742 - if (s_irq_status & S_RX_FIFO_LAST_EN) 743 - qcom_geni_serial_handle_rx(uport, true); 744 - writel(s_irq_status, uport->membase + SE_GENI_S_IRQ_CLEAR); 745 - 746 - status = readl(uport->membase + SE_GENI_STATUS); 747 - if (status & S_GENI_CMD_ACTIVE) 748 - qcom_geni_serial_abort_rx(uport); 749 - } 750 - 751 - static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop) 638 + static void qcom_geni_serial_handle_rx_fifo(struct uart_port *uport, bool drop) 752 639 { 753 640 u32 status; 754 641 u32 word_cnt; 755 642 u32 last_word_byte_cnt; 756 643 u32 last_word_partial; 757 644 u32 total_bytes; 758 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 759 645 760 646 status = readl(uport->membase + SE_GENI_RX_FIFO_STATUS); 761 647 word_cnt = status & RX_FIFO_WC_MSK; ··· 710 716 total_bytes += last_word_byte_cnt; 711 717 else 712 718 total_bytes += BYTES_PER_FIFO_WORD; 713 - port->handle_rx(uport, total_bytes, drop); 719 + handle_rx_console(uport, total_bytes, drop); 714 720 } 715 721 716 - static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done, 717 - bool active) 722 + static void qcom_geni_serial_stop_rx_fifo(struct uart_port *uport) 718 723 { 719 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 724 + u32 irq_en; 725 + struct qcom_geni_serial_port *port = to_dev_port(uport); 726 + u32 s_irq_status; 727 + 728 + irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN); 729 + irq_en &= ~(S_RX_FIFO_WATERMARK_EN | S_RX_FIFO_LAST_EN); 730 + writel(irq_en, uport->membase + SE_GENI_S_IRQ_EN); 731 + 732 + irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 733 + irq_en &= ~(M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN); 734 + writel(irq_en, uport->membase + SE_GENI_M_IRQ_EN); 735 + 736 + if (!qcom_geni_serial_secondary_active(uport)) 737 + return; 738 + 739 + geni_se_cancel_s_cmd(&port->se); 740 + qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS, 741 + S_CMD_CANCEL_EN, true); 742 + /* 743 + * If timeout occurs secondary engine remains active 744 + * and Abort sequence is executed. 745 + */ 746 + s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS); 747 + /* Flush the Rx buffer */ 748 + if (s_irq_status & S_RX_FIFO_LAST_EN) 749 + qcom_geni_serial_handle_rx_fifo(uport, true); 750 + writel(s_irq_status, uport->membase + SE_GENI_S_IRQ_CLEAR); 751 + 752 + if (qcom_geni_serial_secondary_active(uport)) 753 + qcom_geni_serial_abort_rx(uport); 754 + } 755 + 756 + static void qcom_geni_serial_start_rx_fifo(struct uart_port *uport) 757 + { 758 + u32 irq_en; 759 + struct qcom_geni_serial_port *port = to_dev_port(uport); 760 + 761 + if (qcom_geni_serial_secondary_active(uport)) 762 + qcom_geni_serial_stop_rx_fifo(uport); 763 + 764 + geni_se_setup_s_cmd(&port->se, UART_START_READ, 0); 765 + 766 + irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN); 767 + irq_en |= S_RX_FIFO_WATERMARK_EN | S_RX_FIFO_LAST_EN; 768 + writel(irq_en, uport->membase + SE_GENI_S_IRQ_EN); 769 + 770 + irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 771 + irq_en |= M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN; 772 + writel(irq_en, uport->membase + SE_GENI_M_IRQ_EN); 773 + } 774 + 775 + static void qcom_geni_serial_stop_rx_dma(struct uart_port *uport) 776 + { 777 + struct qcom_geni_serial_port *port = to_dev_port(uport); 778 + 779 + if (!qcom_geni_serial_secondary_active(uport)) 780 + return; 781 + 782 + geni_se_cancel_s_cmd(&port->se); 783 + qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS, 784 + S_CMD_CANCEL_EN, true); 785 + 786 + if (qcom_geni_serial_secondary_active(uport)) 787 + qcom_geni_serial_abort_rx(uport); 788 + 789 + if (port->rx_dma_addr) { 790 + geni_se_rx_dma_unprep(&port->se, port->rx_dma_addr, 791 + DMA_RX_BUF_SIZE); 792 + port->rx_dma_addr = 0; 793 + } 794 + } 795 + 796 + static void qcom_geni_serial_start_rx_dma(struct uart_port *uport) 797 + { 798 + struct qcom_geni_serial_port *port = to_dev_port(uport); 799 + int ret; 800 + 801 + if (qcom_geni_serial_secondary_active(uport)) 802 + qcom_geni_serial_stop_rx_dma(uport); 803 + 804 + geni_se_setup_s_cmd(&port->se, UART_START_READ, UART_PARAM_RFR_OPEN); 805 + 806 + ret = geni_se_rx_dma_prep(&port->se, port->rx_buf, 807 + DMA_RX_BUF_SIZE, 808 + &port->rx_dma_addr); 809 + if (ret) { 810 + dev_err(uport->dev, "unable to start RX SE DMA: %d\n", ret); 811 + qcom_geni_serial_stop_rx_dma(uport); 812 + } 813 + } 814 + 815 + static void qcom_geni_serial_handle_rx_dma(struct uart_port *uport, bool drop) 816 + { 817 + struct qcom_geni_serial_port *port = to_dev_port(uport); 818 + u32 rx_in; 819 + int ret; 820 + 821 + if (!qcom_geni_serial_secondary_active(uport)) 822 + return; 823 + 824 + if (!port->rx_dma_addr) 825 + return; 826 + 827 + geni_se_rx_dma_unprep(&port->se, port->rx_dma_addr, DMA_RX_BUF_SIZE); 828 + port->rx_dma_addr = 0; 829 + 830 + rx_in = readl(uport->membase + SE_DMA_RX_LEN_IN); 831 + if (!rx_in) { 832 + dev_warn(uport->dev, "serial engine reports 0 RX bytes in!\n"); 833 + return; 834 + } 835 + 836 + if (!drop) 837 + handle_rx_uart(uport, rx_in, drop); 838 + 839 + ret = geni_se_rx_dma_prep(&port->se, port->rx_buf, 840 + DMA_RX_BUF_SIZE, 841 + &port->rx_dma_addr); 842 + if (ret) { 843 + dev_err(uport->dev, "unable to start RX SE DMA: %d\n", ret); 844 + qcom_geni_serial_stop_rx_dma(uport); 845 + } 846 + } 847 + 848 + static void qcom_geni_serial_start_rx(struct uart_port *uport) 849 + { 850 + uport->ops->start_rx(uport); 851 + } 852 + 853 + static void qcom_geni_serial_stop_rx(struct uart_port *uport) 854 + { 855 + uport->ops->stop_rx(uport); 856 + } 857 + 858 + static void qcom_geni_serial_stop_tx(struct uart_port *uport) 859 + { 860 + uport->ops->stop_tx(uport); 861 + } 862 + 863 + static void qcom_geni_serial_send_chunk_fifo(struct uart_port *uport, 864 + unsigned int chunk) 865 + { 866 + struct qcom_geni_serial_port *port = to_dev_port(uport); 867 + struct circ_buf *xmit = &uport->state->xmit; 868 + unsigned int tx_bytes, c, remaining = chunk; 869 + u8 buf[BYTES_PER_FIFO_WORD]; 870 + 871 + while (remaining) { 872 + memset(buf, 0, sizeof(buf)); 873 + tx_bytes = min(remaining, BYTES_PER_FIFO_WORD); 874 + 875 + for (c = 0; c < tx_bytes ; c++) { 876 + buf[c] = xmit->buf[xmit->tail]; 877 + uart_xmit_advance(uport, 1); 878 + } 879 + 880 + iowrite32_rep(uport->membase + SE_GENI_TX_FIFOn, buf, 1); 881 + 882 + remaining -= tx_bytes; 883 + port->tx_remaining -= tx_bytes; 884 + } 885 + } 886 + 887 + static void qcom_geni_serial_handle_tx_fifo(struct uart_port *uport, 888 + bool done, bool active) 889 + { 890 + struct qcom_geni_serial_port *port = to_dev_port(uport); 720 891 struct circ_buf *xmit = &uport->state->xmit; 721 892 size_t avail; 722 - size_t remaining; 723 893 size_t pending; 724 - int i; 725 894 u32 status; 726 895 u32 irq_en; 727 896 unsigned int chunk; 728 - int tail; 729 897 730 898 status = readl(uport->membase + SE_GENI_TX_FIFO_STATUS); 731 899 ··· 899 743 900 744 /* All data has been transmitted and acknowledged as received */ 901 745 if (!pending && !status && done) { 902 - qcom_geni_serial_stop_tx(uport); 746 + qcom_geni_serial_stop_tx_fifo(uport); 903 747 goto out_write_wakeup; 904 748 } 905 749 906 750 avail = port->tx_fifo_depth - (status & TX_FIFO_WC); 907 751 avail *= BYTES_PER_FIFO_WORD; 908 752 909 - tail = xmit->tail; 910 753 chunk = min(avail, pending); 911 754 if (!chunk) 912 755 goto out_write_wakeup; ··· 920 765 uport->membase + SE_GENI_M_IRQ_EN); 921 766 } 922 767 923 - remaining = chunk; 924 - for (i = 0; i < chunk; ) { 925 - unsigned int tx_bytes; 926 - u8 buf[sizeof(u32)]; 927 - int c; 928 - 929 - memset(buf, 0, sizeof(buf)); 930 - tx_bytes = min_t(size_t, remaining, BYTES_PER_FIFO_WORD); 931 - 932 - for (c = 0; c < tx_bytes ; c++) { 933 - buf[c] = xmit->buf[tail++]; 934 - tail &= UART_XMIT_SIZE - 1; 935 - } 936 - 937 - iowrite32_rep(uport->membase + SE_GENI_TX_FIFOn, buf, 1); 938 - 939 - i += tx_bytes; 940 - uport->icount.tx += tx_bytes; 941 - remaining -= tx_bytes; 942 - port->tx_remaining -= tx_bytes; 943 - } 944 - 945 - xmit->tail = tail; 768 + qcom_geni_serial_send_chunk_fifo(uport, chunk); 946 769 947 770 /* 948 771 * The tx fifo watermark is level triggered and latched. Though we had ··· 942 809 uart_write_wakeup(uport); 943 810 } 944 811 812 + static void qcom_geni_serial_handle_tx_dma(struct uart_port *uport) 813 + { 814 + struct qcom_geni_serial_port *port = to_dev_port(uport); 815 + struct circ_buf *xmit = &uport->state->xmit; 816 + 817 + uart_xmit_advance(uport, port->tx_remaining); 818 + geni_se_tx_dma_unprep(&port->se, port->tx_dma_addr, port->tx_remaining); 819 + port->tx_dma_addr = 0; 820 + port->tx_remaining = 0; 821 + 822 + if (!uart_circ_empty(xmit)) 823 + qcom_geni_serial_start_tx_dma(uport); 824 + 825 + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 826 + uart_write_wakeup(uport); 827 + } 828 + 945 829 static irqreturn_t qcom_geni_serial_isr(int isr, void *dev) 946 830 { 947 831 u32 m_irq_en; 948 832 u32 m_irq_status; 949 833 u32 s_irq_status; 950 834 u32 geni_status; 835 + u32 dma; 836 + u32 dma_tx_status; 837 + u32 dma_rx_status; 951 838 struct uart_port *uport = dev; 952 839 bool drop_rx = false; 953 840 struct tty_port *tport = &uport->state->port; 954 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 841 + struct qcom_geni_serial_port *port = to_dev_port(uport); 955 842 956 843 if (uport->suspended) 957 844 return IRQ_NONE; ··· 980 827 981 828 m_irq_status = readl(uport->membase + SE_GENI_M_IRQ_STATUS); 982 829 s_irq_status = readl(uport->membase + SE_GENI_S_IRQ_STATUS); 830 + dma_tx_status = readl(uport->membase + SE_DMA_TX_IRQ_STAT); 831 + dma_rx_status = readl(uport->membase + SE_DMA_RX_IRQ_STAT); 983 832 geni_status = readl(uport->membase + SE_GENI_STATUS); 833 + dma = readl(uport->membase + SE_GENI_DMA_MODE_EN); 984 834 m_irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 985 835 writel(m_irq_status, uport->membase + SE_GENI_M_IRQ_CLEAR); 986 836 writel(s_irq_status, uport->membase + SE_GENI_S_IRQ_CLEAR); 837 + writel(dma_tx_status, uport->membase + SE_DMA_TX_IRQ_CLR); 838 + writel(dma_rx_status, uport->membase + SE_DMA_RX_IRQ_CLR); 987 839 988 840 if (WARN_ON(m_irq_status & M_ILLEGAL_CMD_EN)) 989 841 goto out_unlock; ··· 998 840 tty_insert_flip_char(tport, 0, TTY_OVERRUN); 999 841 } 1000 842 1001 - if (m_irq_status & m_irq_en & (M_TX_FIFO_WATERMARK_EN | M_CMD_DONE_EN)) 1002 - qcom_geni_serial_handle_tx(uport, m_irq_status & M_CMD_DONE_EN, 1003 - geni_status & M_GENI_CMD_ACTIVE); 1004 - 1005 - if (s_irq_status & S_GP_IRQ_0_EN || s_irq_status & S_GP_IRQ_1_EN) { 843 + if (s_irq_status & (S_GP_IRQ_0_EN | S_GP_IRQ_1_EN)) { 1006 844 if (s_irq_status & S_GP_IRQ_0_EN) 1007 845 uport->icount.parity++; 1008 846 drop_rx = true; 1009 - } else if (s_irq_status & S_GP_IRQ_2_EN || 1010 - s_irq_status & S_GP_IRQ_3_EN) { 847 + } else if (s_irq_status & (S_GP_IRQ_2_EN | S_GP_IRQ_3_EN)) { 1011 848 uport->icount.brk++; 1012 849 port->brk = true; 1013 850 } 1014 851 1015 - if (s_irq_status & S_RX_FIFO_WATERMARK_EN || 1016 - s_irq_status & S_RX_FIFO_LAST_EN) 1017 - qcom_geni_serial_handle_rx(uport, drop_rx); 852 + if (dma) { 853 + if (dma_tx_status & TX_DMA_DONE) 854 + qcom_geni_serial_handle_tx_dma(uport); 855 + 856 + if (dma_rx_status) { 857 + if (dma_rx_status & RX_RESET_DONE) 858 + goto out_unlock; 859 + 860 + if (dma_rx_status & RX_DMA_PARITY_ERR) { 861 + uport->icount.parity++; 862 + drop_rx = true; 863 + } 864 + 865 + if (dma_rx_status & RX_DMA_BREAK) 866 + uport->icount.brk++; 867 + 868 + if (dma_rx_status & (RX_DMA_DONE | RX_EOT)) 869 + qcom_geni_serial_handle_rx_dma(uport, drop_rx); 870 + } 871 + } else { 872 + if (m_irq_status & m_irq_en & 873 + (M_TX_FIFO_WATERMARK_EN | M_CMD_DONE_EN)) 874 + qcom_geni_serial_handle_tx_fifo(uport, 875 + m_irq_status & M_CMD_DONE_EN, 876 + geni_status & M_GENI_CMD_ACTIVE); 877 + 878 + if (s_irq_status & (S_RX_FIFO_WATERMARK_EN | S_RX_FIFO_LAST_EN)) 879 + qcom_geni_serial_handle_rx_fifo(uport, drop_rx); 880 + } 1018 881 1019 882 out_unlock: 1020 883 uart_unlock_and_check_sysrq(uport); ··· 1055 876 uport->fifosize = 1056 877 (port->tx_fifo_depth * port->tx_fifo_width) / BITS_PER_BYTE; 1057 878 1058 - if (port->rx_fifo && (old_rx_fifo_depth != port->rx_fifo_depth) && port->rx_fifo_depth) { 1059 - port->rx_fifo = devm_krealloc(uport->dev, port->rx_fifo, 1060 - port->rx_fifo_depth * sizeof(u32), 1061 - GFP_KERNEL); 1062 - if (!port->rx_fifo) 879 + if (port->rx_buf && (old_rx_fifo_depth != port->rx_fifo_depth) && port->rx_fifo_depth) { 880 + port->rx_buf = devm_krealloc(uport->dev, port->rx_buf, 881 + port->rx_fifo_depth * sizeof(u32), 882 + GFP_KERNEL); 883 + if (!port->rx_buf) 1063 884 return -ENOMEM; 1064 885 } 1065 886 ··· 1070 891 static void qcom_geni_serial_shutdown(struct uart_port *uport) 1071 892 { 1072 893 disable_irq(uport->irq); 894 + qcom_geni_serial_stop_tx(uport); 895 + qcom_geni_serial_stop_rx(uport); 1073 896 } 1074 897 1075 898 static int qcom_geni_serial_port_setup(struct uart_port *uport) 1076 899 { 1077 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 900 + struct qcom_geni_serial_port *port = to_dev_port(uport); 1078 901 u32 rxstale = DEFAULT_BITS_PER_CHAR * STALE_TIMEOUT; 1079 902 u32 proto; 1080 903 u32 pin_swap; ··· 1118 937 geni_se_config_packing(&port->se, BITS_PER_BYTE, BYTES_PER_FIFO_WORD, 1119 938 false, true, true); 1120 939 geni_se_init(&port->se, UART_RX_WM, port->rx_fifo_depth - 2); 1121 - geni_se_select_mode(&port->se, GENI_SE_FIFO); 940 + geni_se_select_mode(&port->se, port->dev_data->mode); 1122 941 qcom_geni_serial_start_rx(uport); 1123 942 port->setup = true; 1124 943 ··· 1128 947 static int qcom_geni_serial_startup(struct uart_port *uport) 1129 948 { 1130 949 int ret; 1131 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 950 + struct qcom_geni_serial_port *port = to_dev_port(uport); 1132 951 1133 952 if (!port->setup) { 1134 953 ret = qcom_geni_serial_port_setup(uport); ··· 1214 1033 u32 stop_bit_len; 1215 1034 unsigned int clk_div; 1216 1035 u32 ser_clk_cfg; 1217 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 1036 + struct qcom_geni_serial_port *port = to_dev_port(uport); 1218 1037 unsigned long clk_rate; 1219 1038 u32 ver, sampling_rate; 1220 1039 unsigned int avg_bw_core; ··· 1316 1135 writel(ser_clk_cfg, uport->membase + GENI_SER_S_CLK_CFG); 1317 1136 out_restart_rx: 1318 1137 qcom_geni_serial_start_rx(uport); 1319 - } 1320 - 1321 - static unsigned int qcom_geni_serial_tx_empty(struct uart_port *uport) 1322 - { 1323 - return !readl(uport->membase + SE_GENI_TX_FIFO_STATUS); 1324 1138 } 1325 1139 1326 1140 #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE ··· 1499 1323 static void qcom_geni_serial_pm(struct uart_port *uport, 1500 1324 unsigned int new_state, unsigned int old_state) 1501 1325 { 1502 - struct qcom_geni_serial_port *port = to_dev_port(uport, uport); 1326 + struct qcom_geni_serial_port *port = to_dev_port(uport); 1503 1327 1504 1328 /* If we've never been called, treat it as off */ 1505 1329 if (old_state == UART_PM_STATE_UNDEFINED) ··· 1517 1341 1518 1342 static const struct uart_ops qcom_geni_console_pops = { 1519 1343 .tx_empty = qcom_geni_serial_tx_empty, 1520 - .stop_tx = qcom_geni_serial_stop_tx, 1521 - .start_tx = qcom_geni_serial_start_tx, 1522 - .stop_rx = qcom_geni_serial_stop_rx, 1523 - .start_rx = qcom_geni_serial_start_rx, 1344 + .stop_tx = qcom_geni_serial_stop_tx_fifo, 1345 + .start_tx = qcom_geni_serial_start_tx_fifo, 1346 + .stop_rx = qcom_geni_serial_stop_rx_fifo, 1347 + .start_rx = qcom_geni_serial_start_rx_fifo, 1524 1348 .set_termios = qcom_geni_serial_set_termios, 1525 1349 .startup = qcom_geni_serial_startup, 1526 1350 .request_port = qcom_geni_serial_request_port, ··· 1538 1362 1539 1363 static const struct uart_ops qcom_geni_uart_pops = { 1540 1364 .tx_empty = qcom_geni_serial_tx_empty, 1541 - .stop_tx = qcom_geni_serial_stop_tx, 1542 - .start_tx = qcom_geni_serial_start_tx, 1543 - .stop_rx = qcom_geni_serial_stop_rx, 1365 + .stop_tx = qcom_geni_serial_stop_tx_dma, 1366 + .start_tx = qcom_geni_serial_start_tx_dma, 1367 + .start_rx = qcom_geni_serial_start_rx_dma, 1368 + .stop_rx = qcom_geni_serial_stop_rx_dma, 1544 1369 .set_termios = qcom_geni_serial_set_termios, 1545 1370 .startup = qcom_geni_serial_startup, 1546 1371 .request_port = qcom_geni_serial_request_port, ··· 1561 1384 struct uart_port *uport; 1562 1385 struct resource *res; 1563 1386 int irq; 1564 - bool console = false; 1565 1387 struct uart_driver *drv; 1388 + const struct qcom_geni_device_data *data; 1566 1389 1567 - if (of_device_is_compatible(pdev->dev.of_node, "qcom,geni-debug-uart")) 1568 - console = true; 1390 + data = of_device_get_match_data(&pdev->dev); 1391 + if (!data) 1392 + return -EINVAL; 1569 1393 1570 - if (console) { 1394 + if (data->console) { 1571 1395 drv = &qcom_geni_console_driver; 1572 1396 line = of_alias_get_id(pdev->dev.of_node, "serial"); 1573 1397 } else { ··· 1578 1400 line = of_alias_get_id(pdev->dev.of_node, "hsuart"); 1579 1401 } 1580 1402 1581 - port = get_port_from_line(line, console); 1403 + port = get_port_from_line(line, data->console); 1582 1404 if (IS_ERR(port)) { 1583 1405 dev_err(&pdev->dev, "Invalid line %d\n", line); 1584 1406 return PTR_ERR(port); ··· 1590 1412 return -ENODEV; 1591 1413 1592 1414 uport->dev = &pdev->dev; 1415 + port->dev_data = data; 1593 1416 port->se.dev = &pdev->dev; 1594 1417 port->se.wrapper = dev_get_drvdata(pdev->dev.parent); 1595 1418 port->se.clk = devm_clk_get(&pdev->dev, "se"); ··· 1609 1430 port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS; 1610 1431 port->tx_fifo_width = DEF_FIFO_WIDTH_BITS; 1611 1432 1612 - if (!console) { 1613 - port->rx_fifo = devm_kcalloc(uport->dev, 1614 - port->rx_fifo_depth, sizeof(u32), GFP_KERNEL); 1615 - if (!port->rx_fifo) 1433 + if (!data->console) { 1434 + port->rx_buf = devm_kzalloc(uport->dev, 1435 + DMA_RX_BUF_SIZE, GFP_KERNEL); 1436 + if (!port->rx_buf) 1616 1437 return -ENOMEM; 1617 1438 } 1618 1439 ··· 1639 1460 uport->irq = irq; 1640 1461 uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE); 1641 1462 1642 - if (!console) 1463 + if (!data->console) 1643 1464 port->wakeup_irq = platform_get_irq_optional(pdev, 1); 1644 1465 1645 1466 if (of_property_read_bool(pdev->dev.of_node, "rx-tx-swap")) ··· 1661 1482 port->private_data.drv = drv; 1662 1483 uport->private_data = &port->private_data; 1663 1484 platform_set_drvdata(pdev, port); 1664 - port->handle_rx = console ? handle_rx_console : handle_rx_uart; 1665 1485 1666 1486 ret = uart_add_one_port(drv, uport); 1667 1487 if (ret) ··· 1772 1594 return ret; 1773 1595 } 1774 1596 1597 + static const struct qcom_geni_device_data qcom_geni_console_data = { 1598 + .console = true, 1599 + .mode = GENI_SE_FIFO, 1600 + }; 1601 + 1602 + static const struct qcom_geni_device_data qcom_geni_uart_data = { 1603 + .console = false, 1604 + .mode = GENI_SE_DMA, 1605 + }; 1606 + 1775 1607 static const struct dev_pm_ops qcom_geni_serial_pm_ops = { 1776 1608 .suspend = pm_sleep_ptr(qcom_geni_serial_sys_suspend), 1777 1609 .resume = pm_sleep_ptr(qcom_geni_serial_sys_resume), ··· 1792 1604 }; 1793 1605 1794 1606 static const struct of_device_id qcom_geni_serial_match_table[] = { 1795 - { .compatible = "qcom,geni-debug-uart", }, 1796 - { .compatible = "qcom,geni-uart", }, 1607 + { 1608 + .compatible = "qcom,geni-debug-uart", 1609 + .data = &qcom_geni_console_data, 1610 + }, 1611 + { 1612 + .compatible = "qcom,geni-uart", 1613 + .data = &qcom_geni_uart_data, 1614 + }, 1797 1615 {} 1798 1616 }; 1799 1617 MODULE_DEVICE_TABLE(of, qcom_geni_serial_match_table);
+26 -25
drivers/tty/serial/sc16is7xx.c
··· 1423 1423 } 1424 1424 sched_set_fifo(s->kworker_task); 1425 1425 1426 - #ifdef CONFIG_GPIOLIB 1427 - if (devtype->nr_gpio) { 1428 - /* Setup GPIO cotroller */ 1429 - s->gpio.owner = THIS_MODULE; 1430 - s->gpio.parent = dev; 1431 - s->gpio.label = dev_name(dev); 1432 - s->gpio.direction_input = sc16is7xx_gpio_direction_input; 1433 - s->gpio.get = sc16is7xx_gpio_get; 1434 - s->gpio.direction_output = sc16is7xx_gpio_direction_output; 1435 - s->gpio.set = sc16is7xx_gpio_set; 1436 - s->gpio.base = -1; 1437 - s->gpio.ngpio = devtype->nr_gpio; 1438 - s->gpio.can_sleep = 1; 1439 - ret = gpiochip_add_data(&s->gpio, s); 1440 - if (ret) 1441 - goto out_thread; 1442 - } 1443 - #endif 1444 - 1445 1426 /* reset device, purging any pending irq / data */ 1446 1427 regmap_write(s->regmap, SC16IS7XX_IOCONTROL_REG << SC16IS7XX_REG_SHIFT, 1447 1428 SC16IS7XX_IOCONTROL_SRESET_BIT); ··· 1499 1518 s->p[u].irda_mode = true; 1500 1519 } 1501 1520 1521 + #ifdef CONFIG_GPIOLIB 1522 + if (devtype->nr_gpio) { 1523 + /* Setup GPIO cotroller */ 1524 + s->gpio.owner = THIS_MODULE; 1525 + s->gpio.parent = dev; 1526 + s->gpio.label = dev_name(dev); 1527 + s->gpio.direction_input = sc16is7xx_gpio_direction_input; 1528 + s->gpio.get = sc16is7xx_gpio_get; 1529 + s->gpio.direction_output = sc16is7xx_gpio_direction_output; 1530 + s->gpio.set = sc16is7xx_gpio_set; 1531 + s->gpio.base = -1; 1532 + s->gpio.ngpio = devtype->nr_gpio; 1533 + s->gpio.can_sleep = 1; 1534 + ret = gpiochip_add_data(&s->gpio, s); 1535 + if (ret) 1536 + goto out_thread; 1537 + } 1538 + #endif 1539 + 1502 1540 /* 1503 1541 * Setup interrupt. We first try to acquire the IRQ line as level IRQ. 1504 1542 * If that succeeds, we can allow sharing the interrupt as well. ··· 1537 1537 if (!ret) 1538 1538 return 0; 1539 1539 1540 - out_ports: 1541 - for (i--; i >= 0; i--) { 1542 - uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); 1543 - clear_bit(s->p[i].port.line, &sc16is7xx_lines); 1544 - } 1545 - 1546 1540 #ifdef CONFIG_GPIOLIB 1547 1541 if (devtype->nr_gpio) 1548 1542 gpiochip_remove(&s->gpio); 1549 1543 1550 1544 out_thread: 1551 1545 #endif 1546 + 1547 + out_ports: 1548 + for (i--; i >= 0; i--) { 1549 + uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); 1550 + clear_bit(s->p[i].port.line, &sc16is7xx_lines); 1551 + } 1552 + 1552 1553 kthread_stop(s->kworker_task); 1553 1554 1554 1555 out_clk:
+1 -11
drivers/tty/serial/sccnxp.c
··· 913 913 } else if (PTR_ERR(s->regulator) == -EPROBE_DEFER) 914 914 return -EPROBE_DEFER; 915 915 916 - clk = devm_clk_get(&pdev->dev, NULL); 916 + clk = devm_clk_get_enabled(&pdev->dev, NULL); 917 917 if (IS_ERR(clk)) { 918 918 ret = PTR_ERR(clk); 919 919 if (ret == -EPROBE_DEFER) 920 920 goto err_out; 921 921 uartclk = 0; 922 922 } else { 923 - ret = clk_prepare_enable(clk); 924 - if (ret) 925 - goto err_out; 926 - 927 - ret = devm_add_action_or_reset(&pdev->dev, 928 - (void(*)(void *))clk_disable_unprepare, 929 - clk); 930 - if (ret) 931 - goto err_out; 932 - 933 923 uartclk = clk_get_rate(clk); 934 924 } 935 925
+6 -1
drivers/tty/serial/serial-tegra.c
··· 1046 1046 if (tup->cdata->fifo_mode_enable_status) { 1047 1047 ret = tegra_uart_wait_fifo_mode_enabled(tup); 1048 1048 if (ret < 0) { 1049 + clk_disable_unprepare(tup->uart_clk); 1049 1050 dev_err(tup->uport.dev, 1050 1051 "Failed to enable FIFO mode: %d\n", ret); 1051 1052 return ret; ··· 1068 1067 */ 1069 1068 ret = tegra_set_baudrate(tup, TEGRA_UART_DEFAULT_BAUD); 1070 1069 if (ret < 0) { 1070 + clk_disable_unprepare(tup->uart_clk); 1071 1071 dev_err(tup->uport.dev, "Failed to set baud rate\n"); 1072 1072 return ret; 1073 1073 } ··· 1228 1226 dev_name(u->dev), tup); 1229 1227 if (ret < 0) { 1230 1228 dev_err(u->dev, "Failed to register ISR for IRQ %d\n", u->irq); 1231 - goto fail_hw_init; 1229 + goto fail_request_irq; 1232 1230 } 1233 1231 return 0; 1234 1232 1233 + fail_request_irq: 1234 + /* tup->uart_clk is already enabled in tegra_uart_hw_init */ 1235 + clk_disable_unprepare(tup->uart_clk); 1235 1236 fail_hw_init: 1236 1237 if (!tup->use_rx_pio) 1237 1238 tegra_uart_dma_channel_free(tup, true);
+44 -33
drivers/tty/serial/serial_core.c
··· 169 169 #define uart_set_mctrl(port, set) uart_update_mctrl(port, set, 0) 170 170 #define uart_clear_mctrl(port, clear) uart_update_mctrl(port, 0, clear) 171 171 172 - static void uart_port_dtr_rts(struct uart_port *uport, int raise) 172 + static void uart_port_dtr_rts(struct uart_port *uport, bool active) 173 173 { 174 - if (raise) 174 + if (active) 175 175 uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS); 176 176 else 177 177 uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); ··· 182 182 * will be serialised by the per-port mutex. 183 183 */ 184 184 static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, 185 - int init_hw) 185 + bool init_hw) 186 186 { 187 187 struct uart_port *uport = uart_port_check(state); 188 188 unsigned long flags; ··· 239 239 * port is open and ready to respond. 240 240 */ 241 241 if (init_hw && C_BAUD(tty)) 242 - uart_port_dtr_rts(uport, 1); 242 + uart_port_dtr_rts(uport, true); 243 243 } 244 244 245 245 /* ··· 254 254 } 255 255 256 256 static int uart_startup(struct tty_struct *tty, struct uart_state *state, 257 - int init_hw) 257 + bool init_hw) 258 258 { 259 259 struct tty_port *port = &state->port; 260 260 int retval; ··· 290 290 set_bit(TTY_IO_ERROR, &tty->flags); 291 291 292 292 if (tty_port_initialized(port)) { 293 - tty_port_set_initialized(port, 0); 293 + tty_port_set_initialized(port, false); 294 294 295 295 /* 296 296 * Turn off DTR and RTS early. ··· 302 302 } 303 303 304 304 if (!tty || C_HUPCL(tty)) 305 - uart_port_dtr_rts(uport, 0); 305 + uart_port_dtr_rts(uport, false); 306 306 307 307 uart_port_shutdown(port); 308 308 } ··· 312 312 * a DCD drop (hangup) at just the right time. Clear suspended bit so 313 313 * we don't try to resume a port that has been shutdown. 314 314 */ 315 - tty_port_set_suspended(port, 0); 315 + tty_port_set_suspended(port, false); 316 316 317 317 /* 318 318 * Do not free() the transmit buffer page under the port lock since ··· 997 997 uart_change_speed(tty, state, NULL); 998 998 } 999 999 } else { 1000 - retval = uart_startup(tty, state, 1); 1000 + retval = uart_startup(tty, state, true); 1001 1001 if (retval == 0) 1002 1002 tty_port_set_initialized(port, true); 1003 1003 if (retval > 0) ··· 1165 1165 */ 1166 1166 uport->ops->config_port(uport, flags); 1167 1167 1168 - ret = uart_startup(tty, state, 1); 1168 + ret = uart_startup(tty, state, true); 1169 1169 if (ret == 0) 1170 1170 tty_port_set_initialized(port, true); 1171 1171 if (ret > 0) ··· 1725 1725 * a DCD drop (hangup) at just the right time. Clear suspended bit so 1726 1726 * we don't try to resume a port that has been shutdown. 1727 1727 */ 1728 - tty_port_set_suspended(port, 0); 1728 + tty_port_set_suspended(port, false); 1729 1729 1730 1730 /* 1731 1731 * Free the transmit buffer. ··· 1827 1827 spin_lock_irqsave(&port->lock, flags); 1828 1828 port->count = 0; 1829 1829 spin_unlock_irqrestore(&port->lock, flags); 1830 - tty_port_set_active(port, 0); 1830 + tty_port_set_active(port, false); 1831 1831 tty_port_tty_set(port, NULL); 1832 1832 if (uport && !uart_console(uport)) 1833 1833 uart_change_pm(state, UART_PM_STATE_OFF); ··· 1861 1861 } 1862 1862 } 1863 1863 1864 - static int uart_carrier_raised(struct tty_port *port) 1864 + static bool uart_carrier_raised(struct tty_port *port) 1865 1865 { 1866 1866 struct uart_state *state = container_of(port, struct uart_state, port); 1867 1867 struct uart_port *uport; ··· 1875 1875 * continue and not sleep 1876 1876 */ 1877 1877 if (WARN_ON(!uport)) 1878 - return 1; 1878 + return true; 1879 1879 spin_lock_irq(&uport->lock); 1880 1880 uart_enable_ms(uport); 1881 1881 mctrl = uport->ops->get_mctrl(uport); 1882 1882 spin_unlock_irq(&uport->lock); 1883 1883 uart_port_deref(uport); 1884 - if (mctrl & TIOCM_CAR) 1885 - return 1; 1886 - return 0; 1884 + 1885 + return mctrl & TIOCM_CAR; 1887 1886 } 1888 1887 1889 - static void uart_dtr_rts(struct tty_port *port, int raise) 1888 + static void uart_dtr_rts(struct tty_port *port, bool active) 1890 1889 { 1891 1890 struct uart_state *state = container_of(port, struct uart_state, port); 1892 1891 struct uart_port *uport; ··· 1893 1894 uport = uart_port_ref(state); 1894 1895 if (!uport) 1895 1896 return; 1896 - uart_port_dtr_rts(uport, raise); 1897 + uart_port_dtr_rts(uport, active); 1897 1898 uart_port_deref(uport); 1898 1899 } 1899 1900 ··· 1942 1943 /* 1943 1944 * Start up the serial port. 1944 1945 */ 1945 - ret = uart_startup(tty, state, 0); 1946 + ret = uart_startup(tty, state, false); 1946 1947 if (ret > 0) 1947 - tty_port_set_active(port, 1); 1948 + tty_port_set_active(port, true); 1948 1949 1949 1950 return ret; 1950 1951 } ··· 2348 2349 int tries; 2349 2350 unsigned int mctrl; 2350 2351 2351 - tty_port_set_suspended(port, 1); 2352 - tty_port_set_initialized(port, 0); 2352 + tty_port_set_suspended(port, true); 2353 + tty_port_set_initialized(port, false); 2353 2354 2354 2355 spin_lock_irq(&uport->lock); 2355 2356 ops->stop_tx(uport); ··· 2460 2461 uart_rs485_config(uport); 2461 2462 ops->start_tx(uport); 2462 2463 spin_unlock_irq(&uport->lock); 2463 - tty_port_set_initialized(port, 1); 2464 + tty_port_set_initialized(port, true); 2464 2465 } else { 2465 2466 /* 2466 2467 * Failed to resume - maybe hardware went away? ··· 2471 2472 } 2472 2473 } 2473 2474 2474 - tty_port_set_suspended(port, 0); 2475 + tty_port_set_suspended(port, false); 2475 2476 } 2476 2477 2477 2478 mutex_unlock(&port->mutex); ··· 3257 3258 /** 3258 3259 * uart_handle_dcd_change - handle a change of carrier detect state 3259 3260 * @uport: uart_port structure for the open port 3260 - * @status: new carrier detect status, nonzero if active 3261 + * @active: new carrier detect status 3261 3262 * 3262 3263 * Caller must hold uport->lock. 3263 3264 */ 3264 - void uart_handle_dcd_change(struct uart_port *uport, unsigned int status) 3265 + void uart_handle_dcd_change(struct uart_port *uport, bool active) 3265 3266 { 3266 3267 struct tty_port *port = &uport->state->port; 3267 3268 struct tty_struct *tty = port->tty; ··· 3273 3274 ld = tty_ldisc_ref(tty); 3274 3275 if (ld) { 3275 3276 if (ld->ops->dcd_change) 3276 - ld->ops->dcd_change(tty, status); 3277 + ld->ops->dcd_change(tty, active); 3277 3278 tty_ldisc_deref(ld); 3278 3279 } 3279 3280 } ··· 3281 3282 uport->icount.dcd++; 3282 3283 3283 3284 if (uart_dcd_enabled(uport)) { 3284 - if (status) 3285 + if (active) 3285 3286 wake_up_interruptible(&port->open_wait); 3286 3287 else if (tty) 3287 3288 tty_hangup(tty); ··· 3292 3293 /** 3293 3294 * uart_handle_cts_change - handle a change of clear-to-send state 3294 3295 * @uport: uart_port structure for the open port 3295 - * @status: new clear to send status, nonzero if active 3296 + * @active: new clear-to-send status 3296 3297 * 3297 3298 * Caller must hold uport->lock. 3298 3299 */ 3299 - void uart_handle_cts_change(struct uart_port *uport, unsigned int status) 3300 + void uart_handle_cts_change(struct uart_port *uport, bool active) 3300 3301 { 3301 3302 lockdep_assert_held_once(&uport->lock); 3302 3303 ··· 3304 3305 3305 3306 if (uart_softcts_mode(uport)) { 3306 3307 if (uport->hw_stopped) { 3307 - if (status) { 3308 + if (active) { 3308 3309 uport->hw_stopped = 0; 3309 3310 uport->ops->start_tx(uport); 3310 3311 uart_write_wakeup(uport); 3311 3312 } 3312 3313 } else { 3313 - if (!status) { 3314 + if (!active) { 3314 3315 uport->hw_stopped = 1; 3315 3316 uport->ops->stop_tx(uport); 3316 3317 } ··· 3414 3415 struct device *dev = port->dev; 3415 3416 u32 rs485_delay[2]; 3416 3417 int ret; 3418 + int rx_during_tx_gpio_flag; 3417 3419 3418 3420 ret = device_property_read_u32_array(dev, "rs485-rts-delay", 3419 3421 rs485_delay, 2); ··· 3462 3462 } 3463 3463 if (port->rs485_term_gpio) 3464 3464 port->rs485_supported.flags |= SER_RS485_TERMINATE_BUS; 3465 + 3466 + rx_during_tx_gpio_flag = (rs485conf->flags & SER_RS485_RX_DURING_TX) ? 3467 + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; 3468 + port->rs485_rx_during_tx_gpio = devm_gpiod_get_optional(dev, 3469 + "rs485-rx-during-tx", 3470 + rx_during_tx_gpio_flag); 3471 + if (IS_ERR(port->rs485_rx_during_tx_gpio)) { 3472 + ret = PTR_ERR(port->rs485_rx_during_tx_gpio); 3473 + port->rs485_rx_during_tx_gpio = NULL; 3474 + return dev_err_probe(dev, ret, "Cannot get rs485-rx-during-tx-gpios\n"); 3475 + } 3465 3476 3466 3477 return 0; 3467 3478 }
+5 -1
drivers/tty/serial/stm32-usart.c
··· 226 226 227 227 stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); 228 228 229 - rs485conf->flags |= SER_RS485_RX_DURING_TX; 229 + if (port->rs485_rx_during_tx_gpio) 230 + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 231 + !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); 232 + else 233 + rs485conf->flags |= SER_RS485_RX_DURING_TX; 230 234 231 235 if (rs485conf->flags & SER_RS485_ENABLED) { 232 236 cr1 = readl_relaxed(port->membase + ofs->cr1);
+4 -4
drivers/tty/serial/sunhv.c
··· 87 87 88 88 if (c == CON_HUP) { 89 89 hung_up = 1; 90 - uart_handle_dcd_change(port, 0); 90 + uart_handle_dcd_change(port, false); 91 91 } else if (hung_up) { 92 92 hung_up = 0; 93 - uart_handle_dcd_change(port, 1); 93 + uart_handle_dcd_change(port, true); 94 94 } 95 95 96 96 if (port->state == NULL) { ··· 133 133 bytes_read = 1; 134 134 } else if (stat == CON_HUP) { 135 135 hung_up = 1; 136 - uart_handle_dcd_change(port, 0); 136 + uart_handle_dcd_change(port, false); 137 137 continue; 138 138 } else { 139 139 /* HV_EWOULDBLOCK, etc. */ ··· 143 143 144 144 if (hung_up) { 145 145 hung_up = 0; 146 - uart_handle_dcd_change(port, 1); 146 + uart_handle_dcd_change(port, true); 147 147 } 148 148 149 149 if (port->sysrq != 0 && *con_read_page) {
+2
drivers/tty/serial/ucc_uart.c
··· 1468 1468 1469 1469 uart_remove_one_port(&ucc_uart_driver, &qe_port->port); 1470 1470 1471 + of_node_put(qe_port->np); 1472 + 1471 1473 kfree(qe_port); 1472 1474 1473 1475 return 0;
+5 -3
drivers/tty/tty_io.c
··· 1224 1224 { 1225 1225 struct tty_struct *tty; 1226 1226 1227 - if (driver->ops->lookup) 1227 + if (driver->ops->lookup) { 1228 1228 if (!file) 1229 1229 tty = ERR_PTR(-EIO); 1230 1230 else 1231 1231 tty = driver->ops->lookup(driver, file, idx); 1232 - else 1232 + } else { 1233 + if (idx >= driver->num) 1234 + return ERR_PTR(-EINVAL); 1233 1235 tty = driver->ttys[idx]; 1234 - 1236 + } 1235 1237 if (!IS_ERR(tty)) 1236 1238 tty_kref_get(tty); 1237 1239 return tty;
+4 -4
drivers/tty/tty_ioctl.c
··· 270 270 * between the two termios structures, or a speed change is needed. 271 271 */ 272 272 273 - int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b) 273 + bool tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b) 274 274 { 275 275 if (a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed) 276 - return 1; 276 + return true; 277 277 if ((a->c_cflag ^ b->c_cflag) & ~(HUPCL | CREAD | CLOCAL)) 278 - return 1; 279 - return 0; 278 + return true; 279 + return false; 280 280 } 281 281 EXPORT_SYMBOL(tty_termios_hw_change); 282 282
+11 -11
drivers/tty/tty_port.c
··· 367 367 goto out; 368 368 369 369 if (tty_port_initialized(port)) { 370 - tty_port_set_initialized(port, 0); 370 + tty_port_set_initialized(port, false); 371 371 /* 372 372 * Drop DTR/RTS if HUPCL is set. This causes any attached 373 373 * modem to hang up the line. ··· 403 403 set_bit(TTY_IO_ERROR, &tty->flags); 404 404 port->tty = NULL; 405 405 spin_unlock_irqrestore(&port->lock, flags); 406 - tty_port_set_active(port, 0); 406 + tty_port_set_active(port, false); 407 407 tty_port_shutdown(port, tty); 408 408 tty_kref_put(tty); 409 409 wake_up_interruptible(&port->open_wait); ··· 444 444 * to hide some internal details. This will eventually become entirely 445 445 * internal to the tty port. 446 446 */ 447 - int tty_port_carrier_raised(struct tty_port *port) 447 + bool tty_port_carrier_raised(struct tty_port *port) 448 448 { 449 449 if (port->ops->carrier_raised == NULL) 450 - return 1; 450 + return true; 451 451 return port->ops->carrier_raised(port); 452 452 } 453 453 EXPORT_SYMBOL(tty_port_carrier_raised); ··· 463 463 void tty_port_raise_dtr_rts(struct tty_port *port) 464 464 { 465 465 if (port->ops->dtr_rts) 466 - port->ops->dtr_rts(port, 1); 466 + port->ops->dtr_rts(port, true); 467 467 } 468 468 EXPORT_SYMBOL(tty_port_raise_dtr_rts); 469 469 ··· 478 478 void tty_port_lower_dtr_rts(struct tty_port *port) 479 479 { 480 480 if (port->ops->dtr_rts) 481 - port->ops->dtr_rts(port, 0); 481 + port->ops->dtr_rts(port, false); 482 482 } 483 483 EXPORT_SYMBOL(tty_port_lower_dtr_rts); 484 484 ··· 518 518 * the port has just hung up or is in another error state. 519 519 */ 520 520 if (tty_io_error(tty)) { 521 - tty_port_set_active(port, 1); 521 + tty_port_set_active(port, true); 522 522 return 0; 523 523 } 524 524 if (filp == NULL || (filp->f_flags & O_NONBLOCK)) { 525 525 /* Indicate we are open */ 526 526 if (C_BAUD(tty)) 527 527 tty_port_raise_dtr_rts(port); 528 - tty_port_set_active(port, 1); 528 + tty_port_set_active(port, true); 529 529 return 0; 530 530 } 531 531 ··· 588 588 port->blocked_open--; 589 589 spin_unlock_irqrestore(&port->lock, flags); 590 590 if (retval == 0) 591 - tty_port_set_active(port, 1); 591 + tty_port_set_active(port, true); 592 592 return retval; 593 593 } 594 594 EXPORT_SYMBOL(tty_port_block_til_ready); ··· 695 695 wake_up_interruptible(&port->open_wait); 696 696 } 697 697 spin_unlock_irqrestore(&port->lock, flags); 698 - tty_port_set_active(port, 0); 698 + tty_port_set_active(port, false); 699 699 } 700 700 EXPORT_SYMBOL(tty_port_close_end); 701 701 ··· 788 788 return retval; 789 789 } 790 790 } 791 - tty_port_set_initialized(port, 1); 791 + tty_port_set_initialized(port, true); 792 792 } 793 793 mutex_unlock(&port->mutex); 794 794 return tty_port_block_til_ready(port, tty, filp);
+136 -176
drivers/tty/vt/vt.c
··· 316 316 * Code to manage unicode-based screen buffers 317 317 */ 318 318 319 - #ifdef NO_VC_UNI_SCREEN 320 - /* this disables and optimizes related code away at compile time */ 321 - #define get_vc_uniscr(vc) NULL 322 - #else 323 - #define get_vc_uniscr(vc) vc->vc_uni_screen 324 - #endif 325 - 326 - #define VC_UNI_SCREEN_DEBUG 0 327 - 328 - typedef uint32_t char32_t; 329 - 330 319 /* 331 320 * Our screen buffer is preceded by an array of line pointers so that 332 321 * scrolling only implies some pointer shuffling. 333 322 */ 334 - struct uni_screen { 335 - char32_t *lines[0]; 336 - }; 337 323 338 - static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows) 324 + static u32 **vc_uniscr_alloc(unsigned int cols, unsigned int rows) 339 325 { 340 - struct uni_screen *uniscr; 326 + u32 **uni_lines; 341 327 void *p; 342 - unsigned int memsize, i; 328 + unsigned int memsize, i, col_size = cols * sizeof(**uni_lines); 343 329 344 330 /* allocate everything in one go */ 345 - memsize = cols * rows * sizeof(char32_t); 346 - memsize += rows * sizeof(char32_t *); 347 - p = vzalloc(memsize); 348 - if (!p) 331 + memsize = col_size * rows; 332 + memsize += rows * sizeof(*uni_lines); 333 + uni_lines = vzalloc(memsize); 334 + if (!uni_lines) 349 335 return NULL; 350 336 351 337 /* initial line pointers */ 352 - uniscr = p; 353 - p = uniscr->lines + rows; 338 + p = uni_lines + rows; 354 339 for (i = 0; i < rows; i++) { 355 - uniscr->lines[i] = p; 356 - p += cols * sizeof(char32_t); 340 + uni_lines[i] = p; 341 + p += col_size; 357 342 } 358 - return uniscr; 343 + 344 + return uni_lines; 359 345 } 360 346 361 - static void vc_uniscr_free(struct uni_screen *uniscr) 347 + static void vc_uniscr_free(u32 **uni_lines) 362 348 { 363 - vfree(uniscr); 349 + vfree(uni_lines); 364 350 } 365 351 366 - static void vc_uniscr_set(struct vc_data *vc, struct uni_screen *new_uniscr) 352 + static void vc_uniscr_set(struct vc_data *vc, u32 **new_uni_lines) 367 353 { 368 - vc_uniscr_free(vc->vc_uni_screen); 369 - vc->vc_uni_screen = new_uniscr; 354 + vc_uniscr_free(vc->vc_uni_lines); 355 + vc->vc_uni_lines = new_uni_lines; 370 356 } 371 357 372 - static void vc_uniscr_putc(struct vc_data *vc, char32_t uc) 358 + static void vc_uniscr_putc(struct vc_data *vc, u32 uc) 373 359 { 374 - struct uni_screen *uniscr = get_vc_uniscr(vc); 375 - 376 - if (uniscr) 377 - uniscr->lines[vc->state.y][vc->state.x] = uc; 360 + if (vc->vc_uni_lines) 361 + vc->vc_uni_lines[vc->state.y][vc->state.x] = uc; 378 362 } 379 363 380 364 static void vc_uniscr_insert(struct vc_data *vc, unsigned int nr) 381 365 { 382 - struct uni_screen *uniscr = get_vc_uniscr(vc); 383 - 384 - if (uniscr) { 385 - char32_t *ln = uniscr->lines[vc->state.y]; 366 + if (vc->vc_uni_lines) { 367 + u32 *ln = vc->vc_uni_lines[vc->state.y]; 386 368 unsigned int x = vc->state.x, cols = vc->vc_cols; 387 369 388 370 memmove(&ln[x + nr], &ln[x], (cols - x - nr) * sizeof(*ln)); ··· 374 392 375 393 static void vc_uniscr_delete(struct vc_data *vc, unsigned int nr) 376 394 { 377 - struct uni_screen *uniscr = get_vc_uniscr(vc); 378 - 379 - if (uniscr) { 380 - char32_t *ln = uniscr->lines[vc->state.y]; 395 + if (vc->vc_uni_lines) { 396 + u32 *ln = vc->vc_uni_lines[vc->state.y]; 381 397 unsigned int x = vc->state.x, cols = vc->vc_cols; 382 398 383 399 memcpy(&ln[x], &ln[x + nr], (cols - x - nr) * sizeof(*ln)); ··· 386 406 static void vc_uniscr_clear_line(struct vc_data *vc, unsigned int x, 387 407 unsigned int nr) 388 408 { 389 - struct uni_screen *uniscr = get_vc_uniscr(vc); 390 - 391 - if (uniscr) { 392 - char32_t *ln = uniscr->lines[vc->state.y]; 393 - 394 - memset32(&ln[x], ' ', nr); 395 - } 409 + if (vc->vc_uni_lines) 410 + memset32(&vc->vc_uni_lines[vc->state.y][x], ' ', nr); 396 411 } 397 412 398 413 static void vc_uniscr_clear_lines(struct vc_data *vc, unsigned int y, 399 414 unsigned int nr) 400 415 { 401 - struct uni_screen *uniscr = get_vc_uniscr(vc); 402 - 403 - if (uniscr) { 404 - unsigned int cols = vc->vc_cols; 405 - 416 + if (vc->vc_uni_lines) 406 417 while (nr--) 407 - memset32(uniscr->lines[y++], ' ', cols); 408 - } 418 + memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols); 409 419 } 410 420 411 - static void vc_uniscr_scroll(struct vc_data *vc, unsigned int t, unsigned int b, 412 - enum con_scroll dir, unsigned int nr) 421 + /* juggling array rotation algorithm (complexity O(N), size complexity O(1)) */ 422 + static void juggle_array(u32 **array, unsigned int size, unsigned int nr) 413 423 { 414 - struct uni_screen *uniscr = get_vc_uniscr(vc); 424 + unsigned int gcd_idx; 415 425 416 - if (uniscr) { 417 - unsigned int i, j, k, sz, d, clear; 426 + for (gcd_idx = 0; gcd_idx < gcd(nr, size); gcd_idx++) { 427 + u32 *gcd_idx_val = array[gcd_idx]; 428 + unsigned int dst_idx = gcd_idx; 418 429 419 - sz = b - t; 420 - clear = b - nr; 421 - d = nr; 422 - if (dir == SM_DOWN) { 423 - clear = t; 424 - d = sz - nr; 430 + while (1) { 431 + unsigned int src_idx = (dst_idx + nr) % size; 432 + if (src_idx == gcd_idx) 433 + break; 434 + 435 + array[dst_idx] = array[src_idx]; 436 + dst_idx = src_idx; 425 437 } 426 - for (i = 0; i < gcd(d, sz); i++) { 427 - char32_t *tmp = uniscr->lines[t + i]; 428 - j = i; 429 - while (1) { 430 - k = j + d; 431 - if (k >= sz) 432 - k -= sz; 433 - if (k == i) 434 - break; 435 - uniscr->lines[t + j] = uniscr->lines[t + k]; 436 - j = k; 437 - } 438 - uniscr->lines[t + j] = tmp; 439 - } 440 - vc_uniscr_clear_lines(vc, clear, nr); 438 + 439 + array[dst_idx] = gcd_idx_val; 441 440 } 442 441 } 443 442 444 - static void vc_uniscr_copy_area(struct uni_screen *dst, 443 + static void vc_uniscr_scroll(struct vc_data *vc, unsigned int top, 444 + unsigned int bottom, enum con_scroll dir, 445 + unsigned int nr) 446 + { 447 + u32 **uni_lines = vc->vc_uni_lines; 448 + unsigned int size = bottom - top; 449 + 450 + if (!uni_lines) 451 + return; 452 + 453 + if (dir == SM_DOWN) { 454 + juggle_array(&uni_lines[top], size, size - nr); 455 + vc_uniscr_clear_lines(vc, top, nr); 456 + } else { 457 + juggle_array(&uni_lines[top], size, nr); 458 + vc_uniscr_clear_lines(vc, bottom - nr, nr); 459 + } 460 + } 461 + 462 + static void vc_uniscr_copy_area(u32 **dst_lines, 445 463 unsigned int dst_cols, 446 464 unsigned int dst_rows, 447 - struct uni_screen *src, 465 + u32 **src_lines, 448 466 unsigned int src_cols, 449 467 unsigned int src_top_row, 450 468 unsigned int src_bot_row) 451 469 { 452 470 unsigned int dst_row = 0; 453 471 454 - if (!dst) 472 + if (!dst_lines) 455 473 return; 456 474 457 475 while (src_top_row < src_bot_row) { 458 - char32_t *src_line = src->lines[src_top_row]; 459 - char32_t *dst_line = dst->lines[dst_row]; 476 + u32 *src_line = src_lines[src_top_row]; 477 + u32 *dst_line = dst_lines[dst_row]; 460 478 461 - memcpy(dst_line, src_line, src_cols * sizeof(char32_t)); 479 + memcpy(dst_line, src_line, src_cols * sizeof(*src_line)); 462 480 if (dst_cols - src_cols) 463 481 memset32(dst_line + src_cols, ' ', dst_cols - src_cols); 464 482 src_top_row++; 465 483 dst_row++; 466 484 } 467 485 while (dst_row < dst_rows) { 468 - char32_t *dst_line = dst->lines[dst_row]; 486 + u32 *dst_line = dst_lines[dst_row]; 469 487 470 488 memset32(dst_line, ' ', dst_cols); 471 489 dst_row++; ··· 478 500 */ 479 501 int vc_uniscr_check(struct vc_data *vc) 480 502 { 481 - struct uni_screen *uniscr; 503 + u32 **uni_lines; 482 504 unsigned short *p; 483 505 int x, y, mask; 484 - 485 - if (__is_defined(NO_VC_UNI_SCREEN)) 486 - return -EOPNOTSUPP; 487 506 488 507 WARN_CONSOLE_UNLOCKED(); 489 508 490 509 if (!vc->vc_utf) 491 510 return -ENODATA; 492 511 493 - if (vc->vc_uni_screen) 512 + if (vc->vc_uni_lines) 494 513 return 0; 495 514 496 - uniscr = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows); 497 - if (!uniscr) 515 + uni_lines = vc_uniscr_alloc(vc->vc_cols, vc->vc_rows); 516 + if (!uni_lines) 498 517 return -ENOMEM; 499 518 500 519 /* ··· 503 528 p = (unsigned short *)vc->vc_origin; 504 529 mask = vc->vc_hi_font_mask | 0xff; 505 530 for (y = 0; y < vc->vc_rows; y++) { 506 - char32_t *line = uniscr->lines[y]; 531 + u32 *line = uni_lines[y]; 507 532 for (x = 0; x < vc->vc_cols; x++) { 508 533 u16 glyph = scr_readw(p++) & mask; 509 534 line[x] = inverse_translate(vc, glyph, true); 510 535 } 511 536 } 512 537 513 - vc->vc_uni_screen = uniscr; 538 + vc->vc_uni_lines = uni_lines; 539 + 514 540 return 0; 515 541 } 516 542 ··· 523 547 void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed, 524 548 unsigned int row, unsigned int col, unsigned int nr) 525 549 { 526 - struct uni_screen *uniscr = get_vc_uniscr(vc); 550 + u32 **uni_lines = vc->vc_uni_lines; 527 551 int offset = row * vc->vc_size_row + col * 2; 528 552 unsigned long pos; 529 553 530 - BUG_ON(!uniscr); 554 + if (WARN_ON_ONCE(!uni_lines)) 555 + return; 531 556 532 557 pos = (unsigned long)screenpos(vc, offset, viewed); 533 558 if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { ··· 539 562 */ 540 563 row = (pos - vc->vc_origin) / vc->vc_size_row; 541 564 col = ((pos - vc->vc_origin) % vc->vc_size_row) / 2; 542 - memcpy(dest, &uniscr->lines[row][col], nr * sizeof(char32_t)); 565 + memcpy(dest, &uni_lines[row][col], nr * sizeof(u32)); 543 566 } else { 544 567 /* 545 568 * Scrollback is active. For now let's simply backtranslate ··· 549 572 */ 550 573 u16 *p = (u16 *)pos; 551 574 int mask = vc->vc_hi_font_mask | 0xff; 552 - char32_t *uni_buf = dest; 575 + u32 *uni_buf = dest; 553 576 while (nr--) { 554 577 u16 glyph = scr_readw(p++) & mask; 555 578 *uni_buf++ = inverse_translate(vc, glyph, true); ··· 557 580 } 558 581 } 559 582 560 - /* this is for validation and debugging only */ 561 - static void vc_uniscr_debug_check(struct vc_data *vc) 583 + static void con_scroll(struct vc_data *vc, unsigned int top, 584 + unsigned int bottom, enum con_scroll dir, 585 + unsigned int nr) 562 586 { 563 - struct uni_screen *uniscr = get_vc_uniscr(vc); 564 - unsigned short *p; 565 - int x, y, mask; 587 + unsigned int rows = bottom - top; 588 + u16 *clear, *dst, *src; 566 589 567 - if (!VC_UNI_SCREEN_DEBUG || !uniscr) 590 + if (top + nr >= bottom) 591 + nr = rows - 1; 592 + if (bottom > vc->vc_rows || top >= bottom || nr < 1) 568 593 return; 569 594 570 - WARN_CONSOLE_UNLOCKED(); 571 - 572 - /* 573 - * Make sure our unicode screen translates into the same glyphs 574 - * as the actual screen. This is brutal indeed. 575 - */ 576 - p = (unsigned short *)vc->vc_origin; 577 - mask = vc->vc_hi_font_mask | 0xff; 578 - for (y = 0; y < vc->vc_rows; y++) { 579 - char32_t *line = uniscr->lines[y]; 580 - for (x = 0; x < vc->vc_cols; x++) { 581 - u16 glyph = scr_readw(p++) & mask; 582 - char32_t uc = line[x]; 583 - int tc = conv_uni_to_pc(vc, uc); 584 - if (tc == -4) 585 - tc = conv_uni_to_pc(vc, 0xfffd); 586 - if (tc == -4) 587 - tc = conv_uni_to_pc(vc, '?'); 588 - if (tc != glyph) 589 - pr_err_ratelimited( 590 - "%s: mismatch at %d,%d: glyph=%#x tc=%#x\n", 591 - __func__, x, y, glyph, tc); 592 - } 593 - } 594 - } 595 - 596 - 597 - static void con_scroll(struct vc_data *vc, unsigned int t, unsigned int b, 598 - enum con_scroll dir, unsigned int nr) 599 - { 600 - u16 *clear, *d, *s; 601 - 602 - if (t + nr >= b) 603 - nr = b - t - 1; 604 - if (b > vc->vc_rows || t >= b || nr < 1) 605 - return; 606 - vc_uniscr_scroll(vc, t, b, dir, nr); 607 - if (con_is_visible(vc) && vc->vc_sw->con_scroll(vc, t, b, dir, nr)) 595 + vc_uniscr_scroll(vc, top, bottom, dir, nr); 596 + if (con_is_visible(vc) && 597 + vc->vc_sw->con_scroll(vc, top, bottom, dir, nr)) 608 598 return; 609 599 610 - s = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * t); 611 - d = (u16 *)(vc->vc_origin + vc->vc_size_row * (t + nr)); 600 + src = clear = (u16 *)(vc->vc_origin + vc->vc_size_row * top); 601 + dst = (u16 *)(vc->vc_origin + vc->vc_size_row * (top + nr)); 612 602 613 603 if (dir == SM_UP) { 614 - clear = s + (b - t - nr) * vc->vc_cols; 615 - swap(s, d); 604 + clear = src + (rows - nr) * vc->vc_cols; 605 + swap(src, dst); 616 606 } 617 - scr_memmovew(d, s, (b - t - nr) * vc->vc_size_row); 607 + scr_memmovew(dst, src, (rows - nr) * vc->vc_size_row); 618 608 scr_memsetw(clear, vc->vc_video_erase_char, vc->vc_size_row * nr); 619 609 } 620 610 ··· 1145 1201 unsigned int new_cols, new_rows, new_row_size, new_screen_size; 1146 1202 unsigned int user; 1147 1203 unsigned short *oldscreen, *newscreen; 1148 - struct uni_screen *new_uniscr = NULL; 1204 + u32 **new_uniscr = NULL; 1149 1205 1150 1206 WARN_CONSOLE_UNLOCKED(); 1151 1207 ··· 1189 1245 if (!newscreen) 1190 1246 return -ENOMEM; 1191 1247 1192 - if (get_vc_uniscr(vc)) { 1248 + if (vc->vc_uni_lines) { 1193 1249 new_uniscr = vc_uniscr_alloc(new_cols, new_rows); 1194 1250 if (!new_uniscr) { 1195 1251 kfree(newscreen); ··· 1241 1297 end = old_origin + old_row_size * min(old_rows, new_rows); 1242 1298 1243 1299 vc_uniscr_copy_area(new_uniscr, new_cols, new_rows, 1244 - get_vc_uniscr(vc), rlth/2, first_copied_row, 1300 + vc->vc_uni_lines, rlth/2, first_copied_row, 1245 1301 min(old_rows, new_rows)); 1246 1302 vc_uniscr_set(vc, new_uniscr); 1247 1303 ··· 2903 2959 goto rescan_last_byte; 2904 2960 } 2905 2961 con_flush(vc, &draw); 2906 - vc_uniscr_debug_check(vc); 2907 2962 console_conditional_schedule(); 2908 2963 notify_update(vc); 2909 2964 console_unlock(); ··· 3099 3156 return console_driver; 3100 3157 } 3101 3158 3159 + static int vt_console_setup(struct console *co, char *options) 3160 + { 3161 + return co->index >= MAX_NR_CONSOLES ? -EINVAL : 0; 3162 + } 3163 + 3102 3164 static struct console vt_console_driver = { 3103 3165 .name = "tty", 3166 + .setup = vt_console_setup, 3104 3167 .write = vt_console_print, 3105 3168 .device = vt_console_device, 3106 3169 .unblank = unblank_screen, ··· 4523 4574 /* 4524 4575 * Font switching 4525 4576 * 4526 - * Currently we only support fonts up to 32 pixels wide, at a maximum height 4527 - * of 32 pixels. Userspace fontdata is stored with 32 bytes (shorts/ints, 4528 - * depending on width) reserved for each character which is kinda wasty, but 4529 - * this is done in order to maintain compatibility with the EGA/VGA fonts. It 4530 - * is up to the actual low-level console-driver convert data into its favorite 4531 - * format (maybe we should add a `fontoffset' field to the `display' 4532 - * structure so we won't have to convert the fontdata all the time. 4577 + * Currently we only support fonts up to 128 pixels wide, at a maximum height 4578 + * of 128 pixels. Userspace fontdata may have to be stored with 32 bytes 4579 + * (shorts/ints, depending on width) reserved for each character which is 4580 + * kinda wasty, but this is done in order to maintain compatibility with the 4581 + * EGA/VGA fonts. It is up to the actual low-level console-driver convert data 4582 + * into its favorite format (maybe we should add a `fontoffset' field to the 4583 + * `display' structure so we won't have to convert the fontdata all the time. 4533 4584 * /Jes 4534 4585 */ 4535 4586 4536 - #define max_font_size 65536 4587 + #define max_font_width 64 4588 + #define max_font_height 128 4589 + #define max_font_glyphs 512 4590 + #define max_font_size (max_font_glyphs*max_font_width*max_font_height) 4537 4591 4538 4592 static int con_font_get(struct vc_data *vc, struct console_font_op *op) 4539 4593 { 4540 4594 struct console_font font; 4541 4595 int rc = -EINVAL; 4542 4596 int c; 4597 + unsigned int vpitch = op->op == KD_FONT_OP_GET_TALL ? op->height : 32; 4543 4598 4544 4599 if (op->data) { 4545 - font.data = kmalloc(max_font_size, GFP_KERNEL); 4600 + font.data = kvmalloc(max_font_size, GFP_KERNEL); 4546 4601 if (!font.data) 4547 4602 return -ENOMEM; 4548 4603 } else ··· 4556 4603 if (vc->vc_mode != KD_TEXT) 4557 4604 rc = -EINVAL; 4558 4605 else if (vc->vc_sw->con_font_get) 4559 - rc = vc->vc_sw->con_font_get(vc, &font); 4606 + rc = vc->vc_sw->con_font_get(vc, &font, vpitch); 4560 4607 else 4561 4608 rc = -ENOSYS; 4562 4609 console_unlock(); ··· 4564 4611 if (rc) 4565 4612 goto out; 4566 4613 4567 - c = (font.width+7)/8 * 32 * font.charcount; 4614 + c = (font.width+7)/8 * vpitch * font.charcount; 4568 4615 4569 4616 if (op->data && font.charcount > op->charcount) 4570 4617 rc = -ENOSPC; ··· 4581 4628 rc = -EFAULT; 4582 4629 4583 4630 out: 4584 - kfree(font.data); 4631 + kvfree(font.data); 4585 4632 return rc; 4586 4633 } 4587 4634 ··· 4590 4637 struct console_font font; 4591 4638 int rc = -EINVAL; 4592 4639 int size; 4640 + unsigned int vpitch = op->op == KD_FONT_OP_SET_TALL ? op->height : 32; 4593 4641 4594 4642 if (vc->vc_mode != KD_TEXT) 4595 4643 return -EINVAL; 4596 4644 if (!op->data) 4597 4645 return -EINVAL; 4598 - if (op->charcount > 512) 4646 + if (op->charcount > max_font_glyphs) 4599 4647 return -EINVAL; 4600 - if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32) 4648 + if (op->width <= 0 || op->width > max_font_width || !op->height || 4649 + op->height > max_font_height) 4601 4650 return -EINVAL; 4602 - size = (op->width+7)/8 * 32 * op->charcount; 4651 + if (vpitch < op->height) 4652 + return -EINVAL; 4653 + size = (op->width+7)/8 * vpitch * op->charcount; 4603 4654 if (size > max_font_size) 4604 4655 return -ENOSPC; 4605 4656 ··· 4621 4664 else if (vc->vc_sw->con_font_set) { 4622 4665 if (vc_is_sel(vc)) 4623 4666 clear_selection(); 4624 - rc = vc->vc_sw->con_font_set(vc, &font, op->flags); 4667 + rc = vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags); 4625 4668 } else 4626 4669 rc = -ENOSYS; 4627 4670 console_unlock(); ··· 4667 4710 { 4668 4711 switch (op->op) { 4669 4712 case KD_FONT_OP_SET: 4713 + case KD_FONT_OP_SET_TALL: 4670 4714 return con_font_set(vc, op); 4671 4715 case KD_FONT_OP_GET: 4716 + case KD_FONT_OP_GET_TALL: 4672 4717 return con_font_get(vc, op); 4673 4718 case KD_FONT_OP_SET_DEFAULT: 4674 4719 return con_font_default(vc, op); ··· 4699 4740 4700 4741 u32 screen_glyph_unicode(const struct vc_data *vc, int n) 4701 4742 { 4702 - struct uni_screen *uniscr = get_vc_uniscr(vc); 4743 + u32 **uni_lines = vc->vc_uni_lines; 4703 4744 4704 - if (uniscr) 4705 - return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols]; 4745 + if (uni_lines) 4746 + return uni_lines[n / vc->vc_cols][n % vc->vc_cols]; 4747 + 4706 4748 return inverse_translate(vc, screen_glyph(vc, n * 2), true); 4707 4749 } 4708 4750 EXPORT_SYMBOL_GPL(screen_glyph_unicode);
+2 -2
drivers/usb/class/cdc-acm.c
··· 651 651 return tty_port_open(&acm->port, tty, filp); 652 652 } 653 653 654 - static void acm_port_dtr_rts(struct tty_port *port, int raise) 654 + static void acm_port_dtr_rts(struct tty_port *port, bool active) 655 655 { 656 656 struct acm *acm = container_of(port, struct acm, port); 657 657 int val; 658 658 int res; 659 659 660 - if (raise) 660 + if (active) 661 661 val = USB_CDC_CTRL_DTR | USB_CDC_CTRL_RTS; 662 662 else 663 663 val = 0;
+1 -1
drivers/usb/serial/console.c
··· 169 169 tty_save_termios(tty); 170 170 tty_kref_put(tty); 171 171 } 172 - tty_port_set_initialized(&port->port, 1); 172 + tty_port_set_initialized(&port->port, true); 173 173 } 174 174 /* Now that any required fake tty operations are completed restore 175 175 * the tty port count */
+3 -3
drivers/usb/serial/usb-serial.c
··· 754 754 return NULL; 755 755 } 756 756 757 - static int serial_port_carrier_raised(struct tty_port *port) 757 + static bool serial_port_carrier_raised(struct tty_port *port) 758 758 { 759 759 struct usb_serial_port *p = container_of(port, struct usb_serial_port, port); 760 760 struct usb_serial_driver *drv = p->serial->type; ··· 762 762 if (drv->carrier_raised) 763 763 return drv->carrier_raised(p); 764 764 /* No carrier control - don't block */ 765 - return 1; 765 + return true; 766 766 } 767 767 768 - static void serial_port_dtr_rts(struct tty_port *port, int on) 768 + static void serial_port_dtr_rts(struct tty_port *port, bool on) 769 769 { 770 770 struct usb_serial_port *p = container_of(port, struct usb_serial_port, port); 771 771 struct usb_serial_driver *drv = p->serial->type;
+5 -4
drivers/video/console/newport_con.c
··· 497 497 return 1; 498 498 } 499 499 500 - static int newport_set_font(int unit, struct console_font *op) 500 + static int newport_set_font(int unit, struct console_font *op, unsigned int vpitch) 501 501 { 502 502 int w = op->width; 503 503 int h = op->height; ··· 507 507 508 508 /* ladis: when I grow up, there will be a day... and more sizes will 509 509 * be supported ;-) */ 510 - if ((w != 8) || (h != 16) 510 + if ((w != 8) || (h != 16) || (vpitch != 32) 511 511 || (op->charcount != 256 && op->charcount != 512)) 512 512 return -EINVAL; 513 513 ··· 569 569 return newport_set_def_font(vc->vc_num, op); 570 570 } 571 571 572 - static int newport_font_set(struct vc_data *vc, struct console_font *font, unsigned flags) 572 + static int newport_font_set(struct vc_data *vc, struct console_font *font, 573 + unsigned int vpitch, unsigned int flags) 573 574 { 574 - return newport_set_font(vc->vc_num, font); 575 + return newport_set_font(vc->vc_num, font, vpitch); 575 576 } 576 577 577 578 static bool newport_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
+5 -4
drivers/video/console/sticon.c
··· 169 169 return 0; 170 170 } 171 171 172 - static int sticon_set_font(struct vc_data *vc, struct console_font *op) 172 + static int sticon_set_font(struct vc_data *vc, struct console_font *op, 173 + unsigned int vpitch) 173 174 { 174 175 struct sti_struct *sti = sticon_sti; 175 176 int vc_cols, vc_rows, vc_old_cols, vc_old_rows; ··· 182 181 struct sti_cooked_font *cooked_font; 183 182 unsigned char *data = op->data, *p; 184 183 185 - if ((w < 6) || (h < 6) || (w > 32) || (h > 32) 184 + if ((w < 6) || (h < 6) || (w > 32) || (h > 32) || (vpitch != 32) 186 185 || (op->charcount != 256 && op->charcount != 512)) 187 186 return -EINVAL; 188 187 pitch = ALIGN(w, 8) / 8; ··· 268 267 } 269 268 270 269 static int sticon_font_set(struct vc_data *vc, struct console_font *font, 271 - unsigned int flags) 270 + unsigned int vpitch, unsigned int flags) 272 271 { 273 - return sticon_set_font(vc, font); 272 + return sticon_set_font(vc, font, vpitch); 274 273 } 275 274 276 275 static void sticon_init(struct vc_data *c, int init)
+4 -4
drivers/video/console/vgacon.c
··· 1029 1029 } 1030 1030 1031 1031 static int vgacon_font_set(struct vc_data *c, struct console_font *font, 1032 - unsigned int flags) 1032 + unsigned int vpitch, unsigned int flags) 1033 1033 { 1034 1034 unsigned charcount = font->charcount; 1035 1035 int rc; ··· 1037 1037 if (vga_video_type < VIDEO_TYPE_EGAM) 1038 1038 return -EINVAL; 1039 1039 1040 - if (font->width != VGA_FONTWIDTH || 1040 + if (font->width != VGA_FONTWIDTH || font->height > 32 || vpitch != 32 || 1041 1041 (charcount != 256 && charcount != 512)) 1042 1042 return -EINVAL; 1043 1043 ··· 1050 1050 return rc; 1051 1051 } 1052 1052 1053 - static int vgacon_font_get(struct vc_data *c, struct console_font *font) 1053 + static int vgacon_font_get(struct vc_data *c, struct console_font *font, unsigned int vpitch) 1054 1054 { 1055 - if (vga_video_type < VIDEO_TYPE_EGAM) 1055 + if (vga_video_type < VIDEO_TYPE_EGAM || vpitch != 32) 1056 1056 return -EINVAL; 1057 1057 1058 1058 font->width = VGA_FONTWIDTH;
+15 -20
drivers/video/fbdev/core/fbcon.c
··· 2266 2266 return 0; 2267 2267 } 2268 2268 2269 - static int fbcon_get_font(struct vc_data *vc, struct console_font *font) 2269 + static int fbcon_get_font(struct vc_data *vc, struct console_font *font, unsigned int vpitch) 2270 2270 { 2271 2271 u8 *fontdata = vc->vc_font.data; 2272 2272 u8 *data = font->data; ··· 2274 2274 2275 2275 font->width = vc->vc_font.width; 2276 2276 font->height = vc->vc_font.height; 2277 + if (font->height > vpitch) 2278 + return -ENOSPC; 2277 2279 font->charcount = vc->vc_hi_font_mask ? 512 : 256; 2278 2280 if (!font->data) 2279 2281 return 0; ··· 2287 2285 2288 2286 for (i = 0; i < font->charcount; i++) { 2289 2287 memcpy(data, fontdata, j); 2290 - memset(data + j, 0, 32 - j); 2291 - data += 32; 2288 + memset(data + j, 0, vpitch - j); 2289 + data += vpitch; 2292 2290 fontdata += j; 2293 2291 } 2294 2292 } else if (font->width <= 16) { ··· 2298 2296 2299 2297 for (i = 0; i < font->charcount; i++) { 2300 2298 memcpy(data, fontdata, j); 2301 - memset(data + j, 0, 64 - j); 2302 - data += 64; 2299 + memset(data + j, 0, 2*vpitch - j); 2300 + data += 2*vpitch; 2303 2301 fontdata += j; 2304 2302 } 2305 2303 } else if (font->width <= 24) { ··· 2313 2311 *data++ = fontdata[2]; 2314 2312 fontdata += sizeof(u32); 2315 2313 } 2316 - memset(data, 0, 3 * (32 - j)); 2317 - data += 3 * (32 - j); 2314 + memset(data, 0, 3 * (vpitch - j)); 2315 + data += 3 * (vpitch - j); 2318 2316 } 2319 2317 } else { 2320 2318 j = vc->vc_font.height * 4; ··· 2323 2321 2324 2322 for (i = 0; i < font->charcount; i++) { 2325 2323 memcpy(data, fontdata, j); 2326 - memset(data + j, 0, 128 - j); 2327 - data += 128; 2324 + memset(data + j, 0, 4 * vpitch - j); 2325 + data += 4 * vpitch; 2328 2326 fontdata += j; 2329 2327 } 2330 2328 } ··· 2459 2457 } 2460 2458 2461 2459 /* 2462 - * User asked to set font; we are guaranteed that 2463 - * a) width and height are in range 1..32 2464 - * b) charcount does not exceed 512 2465 - * but lets not assume that, since someone might someday want to use larger 2466 - * fonts. And charcount of 512 is small for unicode support. 2467 - * 2468 - * However, user space gives the font in 32 rows , regardless of 2469 - * actual font height. So a new API is needed if support for larger fonts 2470 - * is ever implemented. 2460 + * User asked to set font; we are guaranteed that charcount does not exceed 512 2461 + * but lets not assume that, since charcount of 512 is small for unicode support. 2471 2462 */ 2472 2463 2473 2464 static int fbcon_set_font(struct vc_data *vc, struct console_font *font, 2474 - unsigned int flags) 2465 + unsigned int vpitch, unsigned int flags) 2475 2466 { 2476 2467 struct fb_info *info = fbcon_info_from_console(vc->vc_num); 2477 2468 unsigned charcount = font->charcount; ··· 2510 2515 FNTSIZE(new_data) = size; 2511 2516 REFCOUNT(new_data) = 0; /* usage counter */ 2512 2517 for (i=0; i< charcount; i++) { 2513 - memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch); 2518 + memcpy(new_data + i*h*pitch, data + i*vpitch*pitch, h*pitch); 2514 2519 } 2515 2520 2516 2521 /* Since linux has a nice crc32 function use it for counting font
+3 -2
include/linux/console.h
··· 60 60 int (*con_switch)(struct vc_data *vc); 61 61 int (*con_blank)(struct vc_data *vc, int blank, int mode_switch); 62 62 int (*con_font_set)(struct vc_data *vc, struct console_font *font, 63 - unsigned int flags); 64 - int (*con_font_get)(struct vc_data *vc, struct console_font *font); 63 + unsigned int vpitch, unsigned int flags); 64 + int (*con_font_get)(struct vc_data *vc, struct console_font *font, 65 + unsigned int vpitch); 65 66 int (*con_font_default)(struct vc_data *vc, 66 67 struct console_font *font, char *name); 67 68 int (*con_resize)(struct vc_data *vc, unsigned int width,
+1 -2
include/linux/console_struct.h
··· 18 18 #include <linux/workqueue.h> 19 19 20 20 struct uni_pagedict; 21 - struct uni_screen; 22 21 23 22 #define NPAR 16 24 23 #define VC_TABSTOPS_COUNT 256U ··· 158 159 struct vc_data **vc_display_fg; /* [!] Ptr to var holding fg console for this display */ 159 160 struct uni_pagedict *uni_pagedict; 160 161 struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict variable for this console */ 161 - struct uni_screen *vc_uni_screen; /* unicode screen content */ 162 + u32 **vc_uni_lines; /* unicode screen content */ 162 163 /* additional information is in vt_kern.h */ 163 164 }; 164 165
+8
include/linux/dfl.h
··· 27 27 * @id: id of the dfl device. 28 28 * @type: type of DFL FIU of the device. See enum dfl_id_type. 29 29 * @feature_id: feature identifier local to its DFL FIU type. 30 + * @revision: revision of this dfl device feature. 30 31 * @mmio_res: mmio resource of this dfl device. 31 32 * @irqs: list of Linux IRQ numbers of this dfl device. 32 33 * @num_irqs: number of IRQs supported by this dfl device. 33 34 * @cdev: pointer to DFL FPGA container device this dfl device belongs to. 34 35 * @id_entry: matched id entry in dfl driver's id table. 36 + * @dfh_version: version of DFH for the device 37 + * @param_size: size of the block parameters in bytes 38 + * @params: pointer to block of parameters copied memory 35 39 */ 36 40 struct dfl_device { 37 41 struct device dev; ··· 48 44 unsigned int num_irqs; 49 45 struct dfl_fpga_cdev *cdev; 50 46 const struct dfl_device_id *id_entry; 47 + u8 dfh_version; 48 + unsigned int param_size; 49 + void *params; 51 50 }; 52 51 53 52 /** ··· 91 84 module_driver(__dfl_driver, dfl_driver_register, \ 92 85 dfl_driver_unregister) 93 86 87 + void *dfh_find_param(struct dfl_device *dfl_dev, int param_id, size_t *pcount); 94 88 #endif /* __LINUX_DFL_H */
+3
include/linux/qcom-geni-se.h include/linux/soc/qcom/geni-se.h
··· 103 103 #define SE_DMA_TX_FSM_RST 0xc58 104 104 #define SE_DMA_RX_IRQ_STAT 0xd40 105 105 #define SE_DMA_RX_IRQ_CLR 0xd44 106 + #define SE_DMA_RX_LEN_IN 0xd54 106 107 #define SE_DMA_RX_FSM_RST 0xd58 107 108 #define SE_HW_PARAM_0 0xe24 108 109 #define SE_HW_PARAM_1 0xe28 ··· 236 235 #define RX_SBE BIT(2) 237 236 #define RX_RESET_DONE BIT(3) 238 237 #define RX_FLUSH_DONE BIT(4) 238 + #define RX_DMA_PARITY_ERR BIT(5) 239 + #define RX_DMA_BREAK GENMASK(8, 7) 239 240 #define RX_GENI_GP_IRQ GENMASK(10, 5) 240 241 #define RX_GENI_CANCEL_IRQ BIT(11) 241 242 #define RX_GENI_GP_IRQ_EXT GENMASK(13, 12)
+10
include/linux/serial.h
··· 12 12 #include <uapi/linux/serial.h> 13 13 #include <uapi/linux/serial_reg.h> 14 14 15 + #define UART_IER_ALL_INTR (UART_IER_MSI | \ 16 + UART_IER_RLSI | \ 17 + UART_IER_THRI | \ 18 + UART_IER_RDI) 19 + 15 20 /* Helper for dealing with UART_LCR_WLEN* defines */ 16 21 #define UART_LCR_WLEN(x) ((x) - 5) 17 22 ··· 27 22 { 28 23 return (lsr & UART_LSR_BOTH_EMPTY) == UART_LSR_BOTH_EMPTY; 29 24 } 25 + 26 + #define UART_MSR_STATUS_BITS (UART_MSR_DCD | \ 27 + UART_MSR_RI | \ 28 + UART_MSR_DSR | \ 29 + UART_MSR_CTS) 30 30 31 31 /* 32 32 * Counters of the input lines (CTS, DSR, RI, CD) interrupts
+4 -5
include/linux/serial_core.h
··· 579 579 struct serial_rs485 rs485; 580 580 struct serial_rs485 rs485_supported; /* Supported mask for serial_rs485 */ 581 581 struct gpio_desc *rs485_term_gpio; /* enable RS485 bus termination */ 582 + struct gpio_desc *rs485_rx_during_tx_gpio; /* Output GPIO that sets the state of RS485 RX during TX */ 582 583 struct serial_iso7816 iso7816; 583 584 void *private_data; /* generic platform data pointer */ 584 585 }; ··· 782 781 struct earlycon_device { 783 782 struct console *con; 784 783 struct uart_port port; 785 - char options[16]; /* e.g., 115200n8 */ 784 + char options[32]; /* e.g., 115200n8 */ 786 785 unsigned int baud; 787 786 }; 788 787 ··· 897 896 * The following are helper functions for the low level drivers. 898 897 */ 899 898 900 - extern void uart_handle_dcd_change(struct uart_port *uport, 901 - unsigned int status); 902 - extern void uart_handle_cts_change(struct uart_port *uport, 903 - unsigned int status); 899 + extern void uart_handle_dcd_change(struct uart_port *uport, bool active); 900 + extern void uart_handle_cts_change(struct uart_port *uport, bool active); 904 901 905 902 extern void uart_insert_char(struct uart_port *port, unsigned int status, 906 903 unsigned int overrun, unsigned int ch, unsigned int flag);
+1 -1
include/linux/tty.h
··· 453 453 unsigned char tty_get_frame_size(unsigned int cflag); 454 454 455 455 void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old); 456 - int tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b); 456 + bool tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b); 457 457 int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); 458 458 459 459 void tty_wakeup(struct tty_struct *tty);
+2 -2
include/linux/tty_ldisc.h
··· 170 170 * send, please arise a tasklet or workqueue to do the real data transfer. 171 171 * Do not send data in this hook, it may lead to a deadlock. 172 172 * 173 - * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, unsigned int status)`` 173 + * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, bool active)`` 174 174 * 175 175 * Tells the discipline that the DCD pin has changed its status. Used 176 176 * exclusively by the %N_PPS (Pulse-Per-Second) line discipline. ··· 238 238 void (*receive_buf)(struct tty_struct *tty, const unsigned char *cp, 239 239 const char *fp, int count); 240 240 void (*write_wakeup)(struct tty_struct *tty); 241 - void (*dcd_change)(struct tty_struct *tty, unsigned int status); 241 + void (*dcd_change)(struct tty_struct *tty, bool active); 242 242 int (*receive_buf2)(struct tty_struct *tty, const unsigned char *cp, 243 243 const char *fp, int count); 244 244 void (*lookahead_buf)(struct tty_struct *tty, const unsigned char *cp,
+5 -5
include/linux/tty_port.h
··· 15 15 16 16 /** 17 17 * struct tty_port_operations -- operations on tty_port 18 - * @carrier_raised: return 1 if the carrier is raised on @port 19 - * @dtr_rts: raise the DTR line if @raise is nonzero, otherwise lower DTR 18 + * @carrier_raised: return true if the carrier is raised on @port 19 + * @dtr_rts: raise the DTR line if @active is true, otherwise lower DTR 20 20 * @shutdown: called when the last close completes or a hangup finishes IFF the 21 21 * port was initialized. Do not use to free resources. Turn off the device 22 22 * only. Called under the port mutex to serialize against @activate and ··· 31 31 * the port itself. 32 32 */ 33 33 struct tty_port_operations { 34 - int (*carrier_raised)(struct tty_port *port); 35 - void (*dtr_rts)(struct tty_port *port, int raise); 34 + bool (*carrier_raised)(struct tty_port *port); 35 + void (*dtr_rts)(struct tty_port *port, bool active); 36 36 void (*shutdown)(struct tty_port *port); 37 37 int (*activate)(struct tty_port *port, struct tty_struct *tty); 38 38 void (*destruct)(struct tty_port *port); ··· 230 230 231 231 struct tty_struct *tty_port_tty_get(struct tty_port *port); 232 232 void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); 233 - int tty_port_carrier_raised(struct tty_port *port); 233 + bool tty_port_carrier_raised(struct tty_port *port); 234 234 void tty_port_raise_dtr_rts(struct tty_port *port); 235 235 void tty_port_lower_dtr_rts(struct tty_port *port); 236 236 void tty_port_hangup(struct tty_port *port);
+13 -4
include/uapi/linux/gsmmux.h
··· 19 19 unsigned int mtu; 20 20 unsigned int k; 21 21 unsigned int i; 22 - unsigned int unused[8]; /* Padding for expansion without 23 - breaking stuff */ 22 + unsigned int unused[8]; /* Can not be used */ 24 23 }; 25 24 26 25 #define GSMIOC_GETCONF _IOR('G', 0, struct gsm_config) ··· 28 29 struct gsm_netconfig { 29 30 unsigned int adaption; /* Adaption to use in network mode */ 30 31 unsigned short protocol;/* Protocol to use - only ETH_P_IP supported */ 31 - unsigned short unused2; 32 + unsigned short unused2; /* Can not be used */ 32 33 char if_name[IFNAMSIZ]; /* interface name format string */ 33 - __u8 unused[28]; /* For future use */ 34 + __u8 unused[28]; /* Can not be used */ 34 35 }; 35 36 36 37 #define GSMIOC_ENABLE_NET _IOW('G', 2, struct gsm_netconfig) ··· 38 39 39 40 /* get the base tty number for a configured gsmmux tty */ 40 41 #define GSMIOC_GETFIRST _IOR('G', 4, __u32) 42 + 43 + struct gsm_config_ext { 44 + __u32 keep_alive; /* Control channel keep-alive in 1/100th of a 45 + * second (0 to disable) 46 + */ 47 + __u32 reserved[7]; /* For future use, must be initialized to zero */ 48 + }; 49 + 50 + #define GSMIOC_GETCONF_EXT _IOR('G', 5, struct gsm_config_ext) 51 + #define GSMIOC_SETCONF_EXT _IOW('G', 6, struct gsm_config_ext) 41 52 42 53 #endif
+8 -2
include/uapi/linux/kd.h
··· 161 161 unsigned int flags; /* KD_FONT_FLAG_* */ 162 162 unsigned int width, height; /* font size */ 163 163 unsigned int charcount; 164 - unsigned char __user *data; /* font data with height fixed to 32 */ 164 + unsigned char __user *data; /* font data with vpitch fixed to 32 for 165 + * KD_FONT_OP_SET/GET 166 + */ 165 167 }; 166 168 167 169 struct console_font { 168 170 unsigned int width, height; /* font size */ 169 171 unsigned int charcount; 170 - unsigned char *data; /* font data with height fixed to 32 */ 172 + unsigned char *data; /* font data with vpitch fixed to 32 for 173 + * KD_FONT_OP_SET/GET 174 + */ 171 175 }; 172 176 173 177 #define KD_FONT_OP_SET 0 /* Set font */ 174 178 #define KD_FONT_OP_GET 1 /* Get font */ 175 179 #define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */ 176 180 #define KD_FONT_OP_COPY 3 /* Obsolete, do not use */ 181 + #define KD_FONT_OP_SET_TALL 4 /* Set font with vpitch = height */ 182 + #define KD_FONT_OP_GET_TALL 5 /* Get font with vpitch = height */ 177 183 178 184 #define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */ 179 185
+3
include/uapi/linux/serial_core.h
··· 207 207 /* Atheros AR933X SoC */ 208 208 #define PORT_AR933X 99 209 209 210 + /* MCHP 16550A UART with 256 byte FIFOs */ 211 + #define PORT_MCHP16550A 100 212 + 210 213 /* ARC (Synopsys) on-chip UART */ 211 214 #define PORT_ARC 101 212 215
+5
include/uapi/linux/serial_reg.h
··· 44 44 #define UART_IIR_RX_TIMEOUT 0x0c /* OMAP RX Timeout interrupt */ 45 45 #define UART_IIR_XOFF 0x10 /* OMAP XOFF/Special Character */ 46 46 #define UART_IIR_CTS_RTS_DSR 0x20 /* OMAP CTS/RTS/DSR Change */ 47 + #define UART_IIR_64BYTE_FIFO 0x20 /* 16750 64 bytes FIFO */ 48 + #define UART_IIR_FIFO_ENABLED 0xc0 /* FIFOs enabled / port type identification */ 49 + #define UART_IIR_FIFO_ENABLED_8250 0x00 /* 8250: no FIFO */ 50 + #define UART_IIR_FIFO_ENABLED_16550 0x80 /* 16550: (broken/unusable) FIFO */ 51 + #define UART_IIR_FIFO_ENABLED_16550A 0xc0 /* 16550A: FIFO enabled */ 47 52 48 53 #define UART_FCR 2 /* Out: FIFO Control Register */ 49 54 #define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */
+1 -1
net/bluetooth/rfcomm/tty.c
··· 119 119 } 120 120 121 121 /* we block the open until the dlc->state becomes BT_CONNECTED */ 122 - static int rfcomm_dev_carrier_raised(struct tty_port *port) 122 + static bool rfcomm_dev_carrier_raised(struct tty_port *port) 123 123 { 124 124 struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); 125 125