Merge tag 'tty-6.15-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.15-rc1.
Include in here are the following:

- more great tty layer cleanups from Jiri. Someday this will be done,
but that's not going to be any year soon...

- kdb debug driver reverts to fix a reported issue

- lots of .dts binding updates for different devices with serial
devices

- lots of tiny updates and tweaks and a few bugfixes for different
serial drivers.

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

* tag 'tty-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (79 commits)
tty: serial: fsl_lpuart: Fix unused variable 'sport' build warning
serial: stm32: do not deassert RS485 RTS GPIO prematurely
serial: 8250: add driver for NI UARTs
dt-bindings: serial: snps-dw-apb-uart: document RZ/N1 binding without DMA
serial: icom: fix code format problems
serial: sh-sci: Save and restore more registers
tty: serial: pl011: remove incorrect of_match_ptr annotation
dt-bindings: serial: snps-dw-apb-uart: Add support for rk3562
tty: serial: lpuart: only disable CTS instead of overwriting the whole UARTMODIR register
tty: caif: removed unused function debugfs_tx()
serial: 8250_dma: terminate correct DMA in tx_dma_flush()
tty: serial: fsl_lpuart: rename register variables more specifically
tty: serial: fsl_lpuart: use port struct directly to simply code
tty: serial: fsl_lpuart: Use u32 and u8 for register variables
tty: serial: fsl_lpuart: disable transmitter before changing RS485 related registers
tty: serial: 8250: Add Brainboxes XC devices
dt-bindings: serial: fsl-lpuart: support i.MX94
tty: serial: 8250: Add some more device IDs
dt-bindings: serial: samsung: add exynos7870-uart compatible
serial: 8250_dw: Comment possible corner cases in serial_out() implementation
...

+2238 -1462
+1 -1
Documentation/devicetree/bindings/serial/8250.yaml
··· 77 77 - altr,16550-FIFO64 78 78 - altr,16550-FIFO128 79 79 - fsl,16550-FIFO64 80 - - fsl,ns16550 81 80 - andestech,uart16550 82 81 - nxp,lpc1850-uart 83 82 - opencores,uart16550-rtlsvn105 ··· 85 86 - items: 86 87 - enum: 87 88 - ns16750 89 + - fsl,ns16550 88 90 - cavium,octeon-3860-uart 89 91 - xlnx,xps-uart16550-2.00.b 90 92 - ralink,rt2880-uart
+1
Documentation/devicetree/bindings/serial/fsl-lpuart.yaml
··· 30 30 - items: 31 31 - enum: 32 32 - fsl,imx93-lpuart 33 + - fsl,imx94-lpuart 33 34 - fsl,imx95-lpuart 34 35 - const: fsl,imx8ulp-lpuart 35 36 - const: fsl,imx7ulp-lpuart
+73
Documentation/devicetree/bindings/serial/nvidia,tegra264-utc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/serial/nvidia,tegra264-utc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: NVIDIA Tegra UTC (UART Trace Controller) client 8 + 9 + maintainers: 10 + - Kartik Rajput <kkartik@nvidia.com> 11 + - Thierry Reding <thierry.reding@gmail.com> 12 + - Jonathan Hunter <jonathanh@nvidia.com> 13 + 14 + description: 15 + Represents a client interface of the Tegra UTC (UART Trace Controller). The 16 + Tegra UTC allows multiple clients within the Tegra SoC to share a physical 17 + UART interface. It supports up to 16 clients. Each client operates as an 18 + independent UART endpoint with a dedicated interrupt and 128-character TX/RX 19 + FIFOs. 20 + 21 + The Tegra UTC clients use 8-N-1 configuration and operates on a baudrate 22 + configured by the bootloader at the controller level. 23 + 24 + allOf: 25 + - $ref: serial.yaml# 26 + 27 + properties: 28 + compatible: 29 + const: nvidia,tegra264-utc 30 + 31 + reg: 32 + items: 33 + - description: TX region. 34 + - description: RX region. 35 + 36 + reg-names: 37 + items: 38 + - const: tx 39 + - const: rx 40 + 41 + interrupts: 42 + maxItems: 1 43 + 44 + tx-threshold: 45 + minimum: 1 46 + maximum: 128 47 + 48 + rx-threshold: 49 + minimum: 1 50 + maximum: 128 51 + 52 + required: 53 + - compatible 54 + - reg 55 + - reg-names 56 + - interrupts 57 + - tx-threshold 58 + - rx-threshold 59 + 60 + additionalProperties: false 61 + 62 + examples: 63 + - | 64 + #include <dt-bindings/interrupt-controller/arm-gic.h> 65 + 66 + tegra_utc: serial@c4e0000 { 67 + compatible = "nvidia,tegra264-utc"; 68 + reg = <0xc4e0000 0x8000>, <0xc4e8000 0x8000>; 69 + reg-names = "tx", "rx"; 70 + interrupts = <GIC_SPI 514 IRQ_TYPE_LEVEL_HIGH>; 71 + tx-threshold = <4>; 72 + rx-threshold = <4>; 73 + };
+3
Documentation/devicetree/bindings/serial/pl011.yaml
··· 92 92 3000ms. 93 93 default: 3000 94 94 95 + power-domains: 96 + maxItems: 1 97 + 95 98 resets: 96 99 maxItems: 1 97 100
+4
Documentation/devicetree/bindings/serial/samsung_uart.yaml
··· 42 42 - samsung,exynosautov9-uart 43 43 - samsung,exynosautov920-uart 44 44 - const: samsung,exynos850-uart 45 + - items: 46 + - enum: 47 + - samsung,exynos7870-uart 48 + - const: samsung,exynos8895-uart 45 49 46 50 reg: 47 51 maxItems: 1
+21
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
··· 16 16 - if: 17 17 properties: 18 18 compatible: 19 + items: 20 + - enum: 21 + - renesas,r9a06g032-uart 22 + - renesas,r9a06g033-uart 23 + - const: renesas,rzn1-uart 24 + - const: snps,dw-apb-uart 25 + then: 26 + properties: 27 + dmas: false 28 + dma-names: false 29 + 30 + - if: 31 + properties: 32 + compatible: 19 33 contains: 20 34 const: starfive,jh7110-uart 21 35 then: ··· 44 30 properties: 45 31 compatible: 46 32 oneOf: 33 + - items: 34 + - enum: 35 + - renesas,r9a06g032-uart 36 + - renesas,r9a06g033-uart 37 + - const: renesas,rzn1-uart 38 + - const: snps,dw-apb-uart 47 39 - items: 48 40 - enum: 49 41 - renesas,r9a06g032-uart ··· 71 51 - rockchip,rk3368-uart 72 52 - rockchip,rk3399-uart 73 53 - rockchip,rk3528-uart 54 + - rockchip,rk3562-uart 74 55 - rockchip,rk3568-uart 75 56 - rockchip,rk3576-uart 76 57 - rockchip,rk3588-uart
+7 -2
Documentation/devicetree/bindings/serial/sprd-uart.yaml
··· 17 17 oneOf: 18 18 - items: 19 19 - enum: 20 - - sprd,sc9632-uart 20 + - sprd,ums9632-uart 21 + - const: sprd,sc9632-uart 22 + - items: 23 + - enum: 21 24 - sprd,sc9860-uart 22 25 - sprd,sc9863a-uart 23 26 - sprd,ums512-uart 24 27 - sprd,ums9620-uart 25 28 - const: sprd,sc9836-uart 26 - - const: sprd,sc9836-uart 29 + - enum: 30 + - sprd,sc9632-uart 31 + - sprd,sc9836-uart 27 32 28 33 reg: 29 34 maxItems: 1
+2 -2
Documentation/driver-api/serial/driver.rst
··· 101 101 Some helpers are provided in order to set/get modem control lines via GPIO. 102 102 103 103 .. kernel-doc:: drivers/tty/serial/serial_mctrl_gpio.c 104 - :identifiers: mctrl_gpio_init mctrl_gpio_free mctrl_gpio_to_gpiod 104 + :identifiers: mctrl_gpio_init mctrl_gpio_to_gpiod 105 105 mctrl_gpio_set mctrl_gpio_get mctrl_gpio_enable_ms 106 - mctrl_gpio_disable_ms 106 + mctrl_gpio_disable_ms_sync mctrl_gpio_disable_ms_no_sync
+3 -1
Documentation/driver-api/tty/tty_driver.rst
··· 25 25 For reference, both allocation and deallocation functions are explained here in 26 26 detail: 27 27 28 + .. kernel-doc:: include/linux/tty_driver.h 29 + :identifiers: tty_alloc_driver 28 30 .. kernel-doc:: drivers/tty/tty_io.c 29 31 :identifiers: __tty_alloc_driver tty_driver_kref_put 30 32 ··· 37 35 __tty_alloc_driver()): 38 36 39 37 .. kernel-doc:: include/linux/tty_driver.h 40 - :doc: TTY Driver Flags 38 + :identifiers: tty_driver_flag 41 39 42 40 ---- 43 41
+1 -1
Documentation/driver-api/tty/tty_struct.rst
··· 72 72 ================ 73 73 74 74 .. kernel-doc:: include/linux/tty.h 75 - :doc: TTY Struct Flags 75 + :identifiers: tty_struct_flags 76 76 77 77 TTY Struct Reference 78 78 ====================
+6
MAINTAINERS
··· 16550 16550 F: drivers/mtd/nand/ 16551 16551 F: include/linux/mtd/*nand*.h 16552 16552 16553 + NATIONAL INSTRUMENTS SERIAL DRIVER 16554 + M: Chaitanya Vadrevu <chaitanya.vadrevu@emerson.com> 16555 + L: linux-serial@vger.kernel.org 16556 + S: Maintained 16557 + F: drivers/tty/serial/8250/8250_ni.c 16558 + 16553 16559 NATIVE INSTRUMENTS USB SOUND INTERFACE DRIVER 16554 16560 M: Daniel Mack <zonque@gmail.com> 16555 16561 L: linux-sound@vger.kernel.org
+30 -26
arch/alpha/kernel/srmcons.c
··· 196 196 static int __init 197 197 srmcons_init(void) 198 198 { 199 + struct tty_driver *driver; 200 + int err; 201 + 199 202 timer_setup(&srmcons_singleton.timer, srmcons_receive_chars, 0); 200 - if (srm_is_registered_console) { 201 - struct tty_driver *driver; 202 - int err; 203 203 204 - driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0); 205 - if (IS_ERR(driver)) 206 - return PTR_ERR(driver); 204 + if (!srm_is_registered_console) 205 + return -ENODEV; 207 206 208 - tty_port_init(&srmcons_singleton.port); 207 + driver = tty_alloc_driver(MAX_SRM_CONSOLE_DEVICES, 0); 208 + if (IS_ERR(driver)) 209 + return PTR_ERR(driver); 209 210 210 - driver->driver_name = "srm"; 211 - driver->name = "srm"; 212 - driver->major = 0; /* dynamic */ 213 - driver->minor_start = 0; 214 - driver->type = TTY_DRIVER_TYPE_SYSTEM; 215 - driver->subtype = SYSTEM_TYPE_SYSCONS; 216 - driver->init_termios = tty_std_termios; 217 - tty_set_operations(driver, &srmcons_ops); 218 - tty_port_link_device(&srmcons_singleton.port, driver, 0); 219 - err = tty_register_driver(driver); 220 - if (err) { 221 - tty_driver_kref_put(driver); 222 - tty_port_destroy(&srmcons_singleton.port); 223 - return err; 224 - } 225 - srmcons_driver = driver; 226 - } 211 + tty_port_init(&srmcons_singleton.port); 227 212 228 - return -ENODEV; 213 + driver->driver_name = "srm"; 214 + driver->name = "srm"; 215 + driver->major = 0; /* dynamic */ 216 + driver->minor_start = 0; 217 + driver->type = TTY_DRIVER_TYPE_SYSTEM; 218 + driver->subtype = SYSTEM_TYPE_SYSCONS; 219 + driver->init_termios = tty_std_termios; 220 + tty_set_operations(driver, &srmcons_ops); 221 + tty_port_link_device(&srmcons_singleton.port, driver, 0); 222 + err = tty_register_driver(driver); 223 + if (err) 224 + goto err_free_drv; 225 + 226 + srmcons_driver = driver; 227 + 228 + return 0; 229 + err_free_drv: 230 + tty_driver_kref_put(driver); 231 + tty_port_destroy(&srmcons_singleton.port); 232 + 233 + return err; 229 234 } 230 235 device_initcall(srmcons_init); 231 236 232 - 233 237 /* 234 238 * The console driver 235 239 */
+1 -1
drivers/net/caif/caif_serial.c
··· 330 330 ser->tty = tty_kref_get(tty); 331 331 ser->dev = dev; 332 332 debugfs_init(ser, tty); 333 - tty->receive_room = N_TTY_BUF_SIZE; 333 + tty->receive_room = 4096; 334 334 tty->disc_data = ser; 335 335 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 336 336 rtnl_lock();
+2 -2
drivers/staging/greybus/uart.c
··· 948 948 { 949 949 int retval = 0; 950 950 951 - gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, 0); 951 + gb_tty_driver = tty_alloc_driver(GB_NUM_MINORS, TTY_DRIVER_REAL_RAW | 952 + TTY_DRIVER_DYNAMIC_DEV); 952 953 if (IS_ERR(gb_tty_driver)) { 953 954 pr_err("Can not allocate tty driver\n"); 954 955 retval = -ENOMEM; ··· 962 961 gb_tty_driver->minor_start = 0; 963 962 gb_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 964 963 gb_tty_driver->subtype = SERIAL_TYPE_NORMAL; 965 - gb_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 966 964 gb_tty_driver->init_termios = tty_std_termios; 967 965 gb_tty_driver->init_termios.c_cflag = B9600 | CS8 | 968 966 CREAD | HUPCL | CLOCAL;
+1 -1
drivers/tty/Kconfig
··· 210 210 211 211 config MOXA_INTELLIO 212 212 tristate "Moxa Intellio support" 213 - depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) 213 + depends on SERIAL_NONSTANDARD && PCI 214 214 select FW_LOADER 215 215 help 216 216 Say Y here if you have a Moxa Intellio multiport serial card.
+6 -245
drivers/tty/moxa.c
··· 43 43 #include <linux/ratelimit.h> 44 44 45 45 #include <asm/io.h> 46 - #include <linux/uaccess.h> 47 - 48 - #define MOXA 0x400 49 - #define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */ 50 - #define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */ 51 - #define MOXA_GETDATACOUNT (MOXA + 23) 52 - #define MOXA_GET_IOQUEUE (MOXA + 27) 53 - #define MOXA_FLUSH_QUEUE (MOXA + 28) 54 - #define MOXA_GETMSTATUS (MOXA + 65) 55 46 56 47 /* 57 48 * System Configuration ··· 338 347 #define MX_PARMARK 0xA0 339 348 #define MX_PARSPACE 0x20 340 349 341 - #define MOXA_VERSION "6.0k" 342 - 343 350 #define MOXA_FW_HDRLEN 32 344 351 345 352 #define MOXAMAJOR 172 ··· 346 357 #define MAX_PORTS_PER_BOARD 32 /* Don't change this value */ 347 358 #define MAX_PORTS (MAX_BOARDS * MAX_PORTS_PER_BOARD) 348 359 349 - #define MOXA_IS_320(brd) ((brd)->boardType == MOXA_BOARD_C320_ISA || \ 350 - (brd)->boardType == MOXA_BOARD_C320_PCI) 351 - 352 - /* 353 - * Define the Moxa PCI vendor and device IDs. 354 - */ 355 - #define MOXA_BUS_TYPE_ISA 0 356 - #define MOXA_BUS_TYPE_PCI 1 360 + #define MOXA_IS_320(brd) ((brd)->boardType == MOXA_BOARD_C320_PCI) 357 361 358 362 enum { 359 363 MOXA_BOARD_C218_PCI = 1, 360 - MOXA_BOARD_C218_ISA, 361 364 MOXA_BOARD_C320_PCI, 362 - MOXA_BOARD_C320_ISA, 363 365 MOXA_BOARD_CP204J, 364 366 }; 365 367 366 368 static char *moxa_brdname[] = 367 369 { 368 370 "C218 Turbo PCI series", 369 - "C218 Turbo ISA series", 370 371 "C320 Turbo PCI series", 371 - "C320 Turbo ISA series", 372 372 "CP-204J series", 373 373 }; 374 374 375 - #ifdef CONFIG_PCI 376 375 static const struct pci_device_id moxa_pcibrds[] = { 377 376 { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218), 378 377 .driver_data = MOXA_BOARD_C218_PCI }, ··· 371 394 { 0 } 372 395 }; 373 396 MODULE_DEVICE_TABLE(pci, moxa_pcibrds); 374 - #endif /* CONFIG_PCI */ 375 397 376 398 struct moxa_port; 377 399 378 400 static struct moxa_board_conf { 379 401 int boardType; 380 402 int numPorts; 381 - int busType; 382 403 383 404 unsigned int ready; 384 405 ··· 387 412 void __iomem *intPend; 388 413 void __iomem *intTable; 389 414 } moxa_boards[MAX_BOARDS]; 390 - 391 - struct mxser_mstatus { 392 - tcflag_t cflag; 393 - int cts; 394 - int dsr; 395 - int ri; 396 - int dcd; 397 - }; 398 - 399 - struct moxaq_str { 400 - int inq; 401 - int outq; 402 - }; 403 415 404 416 struct moxa_port { 405 417 struct tty_port port; ··· 402 440 u8 lowChkFlag; 403 441 }; 404 442 405 - struct mon_str { 406 - int tick; 407 - int rxcnt[MAX_PORTS]; 408 - int txcnt[MAX_PORTS]; 409 - }; 410 - 411 443 /* statusflags */ 412 444 #define TXSTOPPED 1 413 445 #define LOWWAIT 2 ··· 411 455 #define WAKEUP_CHARS 256 412 456 413 457 static int ttymajor = MOXAMAJOR; 414 - static struct mon_str moxaLog; 415 458 static unsigned int moxaFuncTout = HZ / 2; 416 459 static unsigned int moxaLowWaterChk; 417 460 static DEFINE_MUTEX(moxa_openlock); 418 461 static DEFINE_SPINLOCK(moxa_lock); 419 - 420 - static unsigned long baseaddr[MAX_BOARDS]; 421 - static unsigned int type[MAX_BOARDS]; 422 - static unsigned int numports[MAX_BOARDS]; 423 - static struct tty_port moxa_service_port; 424 462 425 463 MODULE_AUTHOR("William Chen"); 426 464 MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); ··· 422 472 MODULE_FIRMWARE("c218tunx.cod"); 423 473 MODULE_FIRMWARE("cp204unx.cod"); 424 474 MODULE_FIRMWARE("c320tunx.cod"); 425 - 426 - module_param_array(type, uint, NULL, 0); 427 - MODULE_PARM_DESC(type, "card type: C218=2, C320=4"); 428 - module_param_hw_array(baseaddr, ulong, ioport, NULL, 0); 429 - MODULE_PARM_DESC(baseaddr, "base address"); 430 - module_param_array(numports, uint, NULL, 0); 431 - MODULE_PARM_DESC(numports, "numports (ignored for C218)"); 432 475 433 476 module_param(ttymajor, int, 0); 434 477 ··· 526 583 * TTY operations 527 584 */ 528 585 529 - static int moxa_ioctl(struct tty_struct *tty, 530 - unsigned int cmd, unsigned long arg) 531 - { 532 - struct moxa_port *ch = tty->driver_data; 533 - void __user *argp = (void __user *)arg; 534 - int status, ret = 0; 535 - 536 - if (tty->index == MAX_PORTS) { 537 - if (cmd != MOXA_GETDATACOUNT && cmd != MOXA_GET_IOQUEUE && 538 - cmd != MOXA_GETMSTATUS) 539 - return -EINVAL; 540 - } else if (!ch) 541 - return -ENODEV; 542 - 543 - switch (cmd) { 544 - case MOXA_GETDATACOUNT: 545 - moxaLog.tick = jiffies; 546 - if (copy_to_user(argp, &moxaLog, sizeof(moxaLog))) 547 - ret = -EFAULT; 548 - break; 549 - case MOXA_FLUSH_QUEUE: 550 - MoxaPortFlushData(ch, arg); 551 - break; 552 - case MOXA_GET_IOQUEUE: { 553 - struct moxaq_str __user *argm = argp; 554 - struct moxaq_str tmp; 555 - struct moxa_port *p; 556 - unsigned int i, j; 557 - 558 - for (i = 0; i < MAX_BOARDS; i++) { 559 - p = moxa_boards[i].ports; 560 - for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) { 561 - memset(&tmp, 0, sizeof(tmp)); 562 - spin_lock_bh(&moxa_lock); 563 - if (moxa_boards[i].ready) { 564 - tmp.inq = MoxaPortRxQueue(p); 565 - tmp.outq = MoxaPortTxQueue(p); 566 - } 567 - spin_unlock_bh(&moxa_lock); 568 - if (copy_to_user(argm, &tmp, sizeof(tmp))) 569 - return -EFAULT; 570 - } 571 - } 572 - break; 573 - } case MOXA_GET_OQUEUE: 574 - status = MoxaPortTxQueue(ch); 575 - ret = put_user(status, (unsigned long __user *)argp); 576 - break; 577 - case MOXA_GET_IQUEUE: 578 - status = MoxaPortRxQueue(ch); 579 - ret = put_user(status, (unsigned long __user *)argp); 580 - break; 581 - case MOXA_GETMSTATUS: { 582 - struct mxser_mstatus __user *argm = argp; 583 - struct mxser_mstatus tmp; 584 - struct moxa_port *p; 585 - unsigned int i, j; 586 - 587 - for (i = 0; i < MAX_BOARDS; i++) { 588 - p = moxa_boards[i].ports; 589 - for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) { 590 - struct tty_struct *ttyp; 591 - memset(&tmp, 0, sizeof(tmp)); 592 - spin_lock_bh(&moxa_lock); 593 - if (!moxa_boards[i].ready) { 594 - spin_unlock_bh(&moxa_lock); 595 - goto copy; 596 - } 597 - 598 - status = MoxaPortLineStatus(p); 599 - spin_unlock_bh(&moxa_lock); 600 - 601 - if (status & 1) 602 - tmp.cts = 1; 603 - if (status & 2) 604 - tmp.dsr = 1; 605 - if (status & 4) 606 - tmp.dcd = 1; 607 - 608 - ttyp = tty_port_tty_get(&p->port); 609 - if (!ttyp) 610 - tmp.cflag = p->cflag; 611 - else 612 - tmp.cflag = ttyp->termios.c_cflag; 613 - tty_kref_put(ttyp); 614 - copy: 615 - if (copy_to_user(argm, &tmp, sizeof(tmp))) 616 - return -EFAULT; 617 - } 618 - } 619 - break; 620 - } 621 - default: 622 - ret = -ENOIOCTLCMD; 623 - } 624 - return ret; 625 - } 626 - 627 586 static int moxa_break_ctl(struct tty_struct *tty, int state) 628 587 { 629 588 struct moxa_port *port = tty->driver_data; ··· 542 697 .write_room = moxa_write_room, 543 698 .flush_buffer = moxa_flush_buffer, 544 699 .chars_in_buffer = moxa_chars_in_buffer, 545 - .ioctl = moxa_ioctl, 546 700 .set_termios = moxa_set_termios, 547 701 .stop = moxa_stop, 548 702 .start = moxa_start, ··· 569 725 static int moxa_check_fw_model(struct moxa_board_conf *brd, u8 model) 570 726 { 571 727 switch (brd->boardType) { 572 - case MOXA_BOARD_C218_ISA: 573 728 case MOXA_BOARD_C218_PCI: 574 729 if (model != 1) 575 730 goto err; ··· 612 769 msleep(2000); 613 770 614 771 switch (brd->boardType) { 615 - case MOXA_BOARD_C218_ISA: 616 772 case MOXA_BOARD_C218_PCI: 617 773 tmp = readw(baseAddr + C218_key); 618 774 if (tmp != C218_KeyCode) ··· 675 833 676 834 switch (brd->boardType) { 677 835 case MOXA_BOARD_CP204J: 678 - case MOXA_BOARD_C218_ISA: 679 836 case MOXA_BOARD_C218_PCI: 680 837 key = C218_key; 681 838 loadbuf = C218_LoadBuf; ··· 739 898 return -EIO; 740 899 741 900 if (MOXA_IS_320(brd)) { 742 - if (brd->busType == MOXA_BUS_TYPE_PCI) { /* ASIC board */ 743 - writew(0x3800, baseAddr + TMS320_PORT1); 744 - writew(0x3900, baseAddr + TMS320_PORT2); 745 - writew(28499, baseAddr + TMS320_CLOCK); 746 - } else { 747 - writew(0x3200, baseAddr + TMS320_PORT1); 748 - writew(0x3400, baseAddr + TMS320_PORT2); 749 - writew(19999, baseAddr + TMS320_CLOCK); 750 - } 901 + writew(0x3800, baseAddr + TMS320_PORT1); 902 + writew(0x3900, baseAddr + TMS320_PORT2); 903 + writew(28499, baseAddr + TMS320_CLOCK); 751 904 } 752 905 writew(1, baseAddr + Disable_IRQ); 753 906 writew(0, baseAddr + Magic_no); ··· 792 957 return retval; 793 958 794 959 switch (brd->boardType) { 795 - case MOXA_BOARD_C218_ISA: 796 960 case MOXA_BOARD_C218_PCI: 797 961 case MOXA_BOARD_CP204J: 798 962 port = brd->ports; ··· 975 1141 } 976 1142 977 1143 switch (brd->boardType) { 978 - case MOXA_BOARD_C218_ISA: 979 1144 case MOXA_BOARD_C218_PCI: 980 1145 file = "c218tunx.cod"; 981 1146 break; ··· 1060 1227 kfree(brd->ports); 1061 1228 } 1062 1229 1063 - #ifdef CONFIG_PCI 1064 1230 static int moxa_pci_probe(struct pci_dev *pdev, 1065 1231 const struct pci_device_id *ent) 1066 1232 { ··· 1102 1270 1103 1271 board->boardType = board_type; 1104 1272 switch (board_type) { 1105 - case MOXA_BOARD_C218_ISA: 1106 1273 case MOXA_BOARD_C218_PCI: 1107 1274 board->numPorts = 8; 1108 1275 break; ··· 1113 1282 board->numPorts = 0; 1114 1283 break; 1115 1284 } 1116 - board->busType = MOXA_BUS_TYPE_PCI; 1117 1285 1118 1286 retval = moxa_init_board(board, &pdev->dev); 1119 1287 if (retval) ··· 1148 1318 .probe = moxa_pci_probe, 1149 1319 .remove = moxa_pci_remove 1150 1320 }; 1151 - #endif /* CONFIG_PCI */ 1152 1321 1153 1322 static int __init moxa_init(void) 1154 1323 { 1155 - unsigned int isabrds = 0; 1156 1324 int retval = 0; 1157 - struct moxa_board_conf *brd = moxa_boards; 1158 - unsigned int i; 1159 1325 1160 - printk(KERN_INFO "MOXA Intellio family driver version %s\n", 1161 - MOXA_VERSION); 1162 - 1163 - tty_port_init(&moxa_service_port); 1164 - 1165 - moxaDriver = tty_alloc_driver(MAX_PORTS + 1, 1326 + moxaDriver = tty_alloc_driver(MAX_PORTS, 1166 1327 TTY_DRIVER_REAL_RAW | 1167 1328 TTY_DRIVER_DYNAMIC_DEV); 1168 1329 if (IS_ERR(moxaDriver)) ··· 1169 1348 moxaDriver->init_termios.c_ispeed = 9600; 1170 1349 moxaDriver->init_termios.c_ospeed = 9600; 1171 1350 tty_set_operations(moxaDriver, &moxa_ops); 1172 - /* Having one more port only for ioctls is ugly */ 1173 - tty_port_link_device(&moxa_service_port, moxaDriver, MAX_PORTS); 1174 1351 1175 1352 if (tty_register_driver(moxaDriver)) { 1176 1353 printk(KERN_ERR "can't register MOXA Smartio tty driver!\n"); ··· 1176 1357 return -1; 1177 1358 } 1178 1359 1179 - /* Find the boards defined from module args. */ 1180 - 1181 - for (i = 0; i < MAX_BOARDS; i++) { 1182 - if (!baseaddr[i]) 1183 - break; 1184 - if (type[i] == MOXA_BOARD_C218_ISA || 1185 - type[i] == MOXA_BOARD_C320_ISA) { 1186 - pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", 1187 - isabrds + 1, moxa_brdname[type[i] - 1], 1188 - baseaddr[i]); 1189 - brd->boardType = type[i]; 1190 - brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 : 1191 - numports[i]; 1192 - brd->busType = MOXA_BUS_TYPE_ISA; 1193 - brd->basemem = ioremap(baseaddr[i], 0x4000); 1194 - if (!brd->basemem) { 1195 - printk(KERN_ERR "MOXA: can't remap %lx\n", 1196 - baseaddr[i]); 1197 - continue; 1198 - } 1199 - if (moxa_init_board(brd, NULL)) { 1200 - iounmap(brd->basemem); 1201 - brd->basemem = NULL; 1202 - continue; 1203 - } 1204 - 1205 - printk(KERN_INFO "MOXA isa board found at 0x%.8lx and " 1206 - "ready (%u ports, firmware loaded)\n", 1207 - baseaddr[i], brd->numPorts); 1208 - 1209 - brd++; 1210 - isabrds++; 1211 - } 1212 - } 1213 - 1214 - #ifdef CONFIG_PCI 1215 1360 retval = pci_register_driver(&moxa_pci_driver); 1216 - if (retval) { 1361 + if (retval) 1217 1362 printk(KERN_ERR "Can't register MOXA pci driver!\n"); 1218 - if (isabrds) 1219 - retval = 0; 1220 - } 1221 - #endif 1222 1363 1223 1364 return retval; 1224 1365 } 1225 1366 1226 1367 static void __exit moxa_exit(void) 1227 1368 { 1228 - unsigned int i; 1229 - 1230 - #ifdef CONFIG_PCI 1231 1369 pci_unregister_driver(&moxa_pci_driver); 1232 - #endif 1233 - 1234 - for (i = 0; i < MAX_BOARDS; i++) /* ISA boards */ 1235 - if (moxa_boards[i].ready) 1236 - moxa_board_deinit(&moxa_boards[i]); 1237 1370 1238 1371 del_timer_sync(&moxaTimer); 1239 1372 ··· 1228 1457 int port; 1229 1458 1230 1459 port = tty->index; 1231 - if (port == MAX_PORTS) { 1232 - return capable(CAP_SYS_ADMIN) ? 0 : -EPERM; 1233 - } 1234 1460 if (mutex_lock_interruptible(&moxa_openlock)) 1235 1461 return -ERESTARTSYS; 1236 1462 brd = &moxa_boards[port / MAX_PORTS_PER_BOARD]; ··· 1950 2182 c = (head > tail) ? (head - tail - 1) : (head - tail + tx_mask); 1951 2183 if (c > len) 1952 2184 c = len; 1953 - moxaLog.txcnt[port->port.tty->index] += c; 1954 2185 total = c; 1955 2186 if (spage == epage) { 1956 2187 bufhead = readw(ofsAddr + Ofs_txb); ··· 1991 2224 1992 2225 static int MoxaPortReadData(struct moxa_port *port) 1993 2226 { 1994 - struct tty_struct *tty = port->port.tty; 1995 2227 void __iomem *baseAddr, *ofsAddr, *ofs; 1996 2228 u8 *dst; 1997 2229 unsigned int count, len, total; ··· 2009 2243 return 0; 2010 2244 2011 2245 total = count; 2012 - moxaLog.rxcnt[tty->index] += total; 2013 2246 if (spage == epage) { 2014 2247 bufhead = readw(ofsAddr + Ofs_rxb); 2015 2248 writew(spage, baseAddr + Control_reg); ··· 2096 2331 { 2097 2332 struct moxa_port *info = tty->driver_data; 2098 2333 2099 - if (tty->index == MAX_PORTS) 2100 - return -EINVAL; 2101 2334 if (!info) 2102 2335 return -ENODEV; 2103 2336 mutex_lock(&info->port.mutex); ··· 2115 2352 struct moxa_port *info = tty->driver_data; 2116 2353 unsigned int close_delay; 2117 2354 2118 - if (tty->index == MAX_PORTS) 2119 - return -EINVAL; 2120 2355 if (!info) 2121 2356 return -ENODEV; 2122 2357
+100 -112
drivers/tty/n_tty.c
··· 56 56 */ 57 57 #define WAKEUP_CHARS 256 58 58 59 + #define N_TTY_BUF_SIZE 4096 60 + 59 61 /* 60 62 * This defines the low- and high-watermarks for throttling and 61 63 * unthrottling the TTY driver. These watermarks are used for ··· 80 78 #define ECHO_COMMIT_WATERMARK 256 81 79 #define ECHO_BLOCK 256 82 80 #define ECHO_DISCARD_WATERMARK N_TTY_BUF_SIZE - (ECHO_BLOCK + 32) 83 - 84 - 85 - #undef N_TTY_TRACE 86 - #ifdef N_TTY_TRACE 87 - # define n_tty_trace(f, args...) trace_printk(f, ##args) 88 - #else 89 - # define n_tty_trace(f, args...) no_printk(f, ##args) 90 - #endif 91 81 92 82 struct n_tty_data { 93 83 /* producer-published */ ··· 480 486 static int process_output(u8 c, struct tty_struct *tty) 481 487 { 482 488 struct n_tty_data *ldata = tty->disc_data; 483 - int space, retval; 484 489 485 - mutex_lock(&ldata->output_lock); 490 + guard(mutex)(&ldata->output_lock); 486 491 487 - space = tty_write_room(tty); 488 - retval = do_output_char(c, tty, space); 489 - 490 - mutex_unlock(&ldata->output_lock); 491 - if (retval < 0) 492 + if (do_output_char(c, tty, tty_write_room(tty)) < 0) 492 493 return -1; 493 - else 494 - return 0; 494 + 495 + return 0; 495 496 } 496 497 497 498 /** ··· 511 522 const u8 *buf, unsigned int nr) 512 523 { 513 524 struct n_tty_data *ldata = tty->disc_data; 514 - int space; 515 - int i; 525 + unsigned int space, i; 516 526 const u8 *cp; 517 527 518 - mutex_lock(&ldata->output_lock); 528 + guard(mutex)(&ldata->output_lock); 519 529 520 530 space = tty_write_room(tty); 521 - if (space <= 0) { 522 - mutex_unlock(&ldata->output_lock); 523 - return space; 524 - } 531 + if (space == 0) 532 + return 0; 533 + 525 534 if (nr > space) 526 535 nr = space; 527 536 ··· 531 544 if (O_ONLRET(tty)) 532 545 ldata->column = 0; 533 546 if (O_ONLCR(tty)) 534 - goto break_out; 547 + goto do_write; 535 548 ldata->canon_column = ldata->column; 536 549 break; 537 550 case '\r': 538 551 if (O_ONOCR(tty) && ldata->column == 0) 539 - goto break_out; 552 + goto do_write; 540 553 if (O_OCRNL(tty)) 541 - goto break_out; 554 + goto do_write; 542 555 ldata->canon_column = ldata->column = 0; 543 556 break; 544 557 case '\t': 545 - goto break_out; 558 + goto do_write; 546 559 case '\b': 547 560 if (ldata->column > 0) 548 561 ldata->column--; ··· 550 563 default: 551 564 if (!iscntrl(c)) { 552 565 if (O_OLCUC(tty)) 553 - goto break_out; 566 + goto do_write; 554 567 if (!is_continuation(c, tty)) 555 568 ldata->column++; 556 569 } 557 570 break; 558 571 } 559 572 } 560 - break_out: 561 - i = tty->ops->write(tty, buf, i); 562 - 563 - mutex_unlock(&ldata->output_lock); 564 - return i; 573 + do_write: 574 + return tty->ops->write(tty, buf, i); 565 575 } 566 576 567 577 static int n_tty_process_echo_ops(struct tty_struct *tty, size_t *tail, ··· 680 696 static size_t __process_echoes(struct tty_struct *tty) 681 697 { 682 698 struct n_tty_data *ldata = tty->disc_data; 683 - int space, old_space; 699 + unsigned int space, old_space; 684 700 size_t tail; 685 701 u8 c; 686 702 ··· 2018 2034 tail = MASK(ldata->read_tail); 2019 2035 size = min_t(size_t, tail + n, N_TTY_BUF_SIZE); 2020 2036 2021 - n_tty_trace("%s: nr:%zu tail:%zu n:%zu size:%zu\n", 2022 - __func__, *nr, tail, n, size); 2023 - 2024 2037 eol = find_next_bit(ldata->read_flags, size, tail); 2025 2038 more = n - (size - tail); 2026 2039 if (eol == N_TTY_BUF_SIZE && more) { ··· 2034 2053 2035 2054 if (!found || read_buf(ldata, eol) != __DISABLED_CHAR) 2036 2055 n = c; 2037 - 2038 - n_tty_trace("%s: eol:%zu found:%d n:%zu c:%zu tail:%zu more:%zu\n", 2039 - __func__, eol, found, n, c, tail, more); 2040 2056 2041 2057 tty_copy(tty, *kbp, tail, n); 2042 2058 *kbp += n; ··· 2111 2133 return __tty_check_change(tty, SIGTTIN); 2112 2134 } 2113 2135 2136 + /* 2137 + * We still hold the atomic_read_lock and the termios_rwsem, and can just 2138 + * continue to copy data. 2139 + */ 2140 + static ssize_t n_tty_continue_cookie(struct tty_struct *tty, u8 *kbuf, 2141 + size_t nr, void **cookie) 2142 + { 2143 + struct n_tty_data *ldata = tty->disc_data; 2144 + u8 *kb = kbuf; 2145 + 2146 + if (ldata->icanon && !L_EXTPROC(tty)) { 2147 + /* 2148 + * If we have filled the user buffer, see if we should skip an 2149 + * EOF character before releasing the lock and returning done. 2150 + */ 2151 + if (!nr) 2152 + canon_skip_eof(ldata); 2153 + else if (canon_copy_from_read_buf(tty, &kb, &nr)) 2154 + return kb - kbuf; 2155 + } else { 2156 + if (copy_from_read_buf(tty, &kb, &nr)) 2157 + return kb - kbuf; 2158 + } 2159 + 2160 + /* No more data - release locks and stop retries */ 2161 + n_tty_kick_worker(tty); 2162 + n_tty_check_unthrottle(tty); 2163 + up_read(&tty->termios_rwsem); 2164 + mutex_unlock(&ldata->atomic_read_lock); 2165 + *cookie = NULL; 2166 + 2167 + return kb - kbuf; 2168 + } 2169 + 2170 + static int n_tty_wait_for_input(struct tty_struct *tty, struct file *file, 2171 + struct wait_queue_entry *wait, long *timeout) 2172 + { 2173 + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) 2174 + return -EIO; 2175 + if (tty_hung_up_p(file)) 2176 + return 0; 2177 + /* 2178 + * Abort readers for ttys which never actually get hung up. 2179 + * See __tty_hangup(). 2180 + */ 2181 + if (test_bit(TTY_HUPPING, &tty->flags)) 2182 + return 0; 2183 + if (!*timeout) 2184 + return 0; 2185 + if (tty_io_nonblock(tty, file)) 2186 + return -EAGAIN; 2187 + if (signal_pending(current)) 2188 + return -ERESTARTSYS; 2189 + 2190 + up_read(&tty->termios_rwsem); 2191 + *timeout = wait_woken(wait, TASK_INTERRUPTIBLE, *timeout); 2192 + down_read(&tty->termios_rwsem); 2193 + 2194 + return 1; 2195 + } 2114 2196 2115 2197 /** 2116 2198 * n_tty_read - read function for tty ··· 2204 2166 bool packet; 2205 2167 size_t old_tail; 2206 2168 2207 - /* 2208 - * Is this a continuation of a read started earler? 2209 - * 2210 - * If so, we still hold the atomic_read_lock and the 2211 - * termios_rwsem, and can just continue to copy data. 2212 - */ 2213 - if (*cookie) { 2214 - if (ldata->icanon && !L_EXTPROC(tty)) { 2215 - /* 2216 - * If we have filled the user buffer, see 2217 - * if we should skip an EOF character before 2218 - * releasing the lock and returning done. 2219 - */ 2220 - if (!nr) 2221 - canon_skip_eof(ldata); 2222 - else if (canon_copy_from_read_buf(tty, &kb, &nr)) 2223 - return kb - kbuf; 2224 - } else { 2225 - if (copy_from_read_buf(tty, &kb, &nr)) 2226 - return kb - kbuf; 2227 - } 2228 - 2229 - /* No more data - release locks and stop retries */ 2230 - n_tty_kick_worker(tty); 2231 - n_tty_check_unthrottle(tty); 2232 - up_read(&tty->termios_rwsem); 2233 - mutex_unlock(&ldata->atomic_read_lock); 2234 - *cookie = NULL; 2235 - return kb - kbuf; 2236 - } 2169 + /* Is this a continuation of a read started earlier? */ 2170 + if (*cookie) 2171 + return n_tty_continue_cookie(tty, kbuf, nr, cookie); 2237 2172 2238 2173 retval = job_control(tty, file); 2239 2174 if (retval < 0) ··· 2261 2250 tty_buffer_flush_work(tty->port); 2262 2251 down_read(&tty->termios_rwsem); 2263 2252 if (!input_available_p(tty, 0)) { 2264 - if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { 2265 - retval = -EIO; 2253 + int ret = n_tty_wait_for_input(tty, file, &wait, 2254 + &timeout); 2255 + if (ret <= 0) { 2256 + retval = ret; 2266 2257 break; 2267 2258 } 2268 - if (tty_hung_up_p(file)) 2269 - break; 2270 - /* 2271 - * Abort readers for ttys which never actually 2272 - * get hung up. See __tty_hangup(). 2273 - */ 2274 - if (test_bit(TTY_HUPPING, &tty->flags)) 2275 - break; 2276 - if (!timeout) 2277 - break; 2278 - if (tty_io_nonblock(tty, file)) { 2279 - retval = -EAGAIN; 2280 - break; 2281 - } 2282 - if (signal_pending(current)) { 2283 - retval = -ERESTARTSYS; 2284 - break; 2285 - } 2286 - up_read(&tty->termios_rwsem); 2287 - 2288 - timeout = wait_woken(&wait, TASK_INTERRUPTIBLE, 2289 - timeout); 2290 - 2291 - down_read(&tty->termios_rwsem); 2292 2259 continue; 2293 2260 } 2294 2261 } ··· 2281 2292 nr--; 2282 2293 } 2283 2294 2284 - /* 2285 - * Copy data, and if there is more to be had 2286 - * and we have nothing more to wait for, then 2287 - * let's mark us for retries. 2288 - * 2289 - * NOTE! We return here with both the termios_sem 2290 - * and atomic_read_lock still held, the retries 2291 - * will release them when done. 2292 - */ 2293 - if (copy_from_read_buf(tty, &kb, &nr) && kb - kbuf >= minimum) { 2294 - more_to_be_read: 2295 - remove_wait_queue(&tty->read_wait, &wait); 2296 - *cookie = cookie; 2297 - return kb - kbuf; 2298 - } 2295 + if (copy_from_read_buf(tty, &kb, &nr) && kb - kbuf >= minimum) 2296 + goto more_to_be_read; 2299 2297 } 2300 2298 2301 2299 n_tty_check_unthrottle(tty); ··· 2309 2333 retval = kb - kbuf; 2310 2334 2311 2335 return retval; 2336 + more_to_be_read: 2337 + /* 2338 + * There is more to be had and we have nothing more to wait for, so 2339 + * let's mark us for retries. 2340 + * 2341 + * NOTE! We return here with both the termios_sem and atomic_read_lock 2342 + * still held, the retries will release them when done. 2343 + */ 2344 + remove_wait_queue(&tty->read_wait, &wait); 2345 + *cookie = cookie; 2346 + 2347 + return kb - kbuf; 2312 2348 } 2313 2349 2314 2350 /**
-11
drivers/tty/serdev/core.c
··· 316 316 } 317 317 EXPORT_SYMBOL_GPL(serdev_device_write_flush); 318 318 319 - int serdev_device_write_room(struct serdev_device *serdev) 320 - { 321 - struct serdev_controller *ctrl = serdev->ctrl; 322 - 323 - if (!ctrl || !ctrl->ops->write_room) 324 - return 0; 325 - 326 - return serdev->ctrl->ops->write_room(ctrl); 327 - } 328 - EXPORT_SYMBOL_GPL(serdev_device_write_room); 329 - 330 319 unsigned int serdev_device_set_baudrate(struct serdev_device *serdev, unsigned int speed) 331 320 { 332 321 struct serdev_controller *ctrl = serdev->ctrl;
-9
drivers/tty/serdev/serdev-ttyport.c
··· 92 92 tty_driver_flush_buffer(tty); 93 93 } 94 94 95 - static int ttyport_write_room(struct serdev_controller *ctrl) 96 - { 97 - struct serport *serport = serdev_controller_get_drvdata(ctrl); 98 - struct tty_struct *tty = serport->tty; 99 - 100 - return tty_write_room(tty); 101 - } 102 - 103 95 static int ttyport_open(struct serdev_controller *ctrl) 104 96 { 105 97 struct serport *serport = serdev_controller_get_drvdata(ctrl); ··· 251 259 static const struct serdev_controller_ops ctrl_ops = { 252 260 .write_buf = ttyport_write_buf, 253 261 .write_flush = ttyport_write_flush, 254 - .write_room = ttyport_write_room, 255 262 .open = ttyport_open, 256 263 .close = ttyport_close, 257 264 .set_flow_control = ttyport_set_flow_control,
+1 -1
drivers/tty/serial/8250/8250_dma.c
··· 162 162 */ 163 163 dma->tx_size = 0; 164 164 165 - dmaengine_terminate_async(dma->rxchan); 165 + dmaengine_terminate_async(dma->txchan); 166 166 } 167 167 168 168 int serial8250_rx_dma(struct uart_8250_port *p)
+48 -25
drivers/tty/serial/8250/8250_dw.c
··· 107 107 return value; 108 108 } 109 109 110 + /* 111 + * This function is being called as part of the uart_port::serial_out() 112 + * routine. Hence, it must not call serial_port_out() or serial_out() 113 + * against the modified registers here, i.e. LCR. 114 + */ 110 115 static void dw8250_force_idle(struct uart_port *p) 111 116 { 112 117 struct uart_8250_port *up = up_to_u8250p(p); 113 118 unsigned int lsr; 114 119 120 + /* 121 + * The following call currently performs serial_out() 122 + * against the FCR register. Because it differs to LCR 123 + * there will be no infinite loop, but if it ever gets 124 + * modified, we might need a new custom version of it 125 + * that avoids infinite recursion. 126 + */ 115 127 serial8250_clear_and_reinit_fifos(up); 116 128 117 129 /* ··· 132 120 * enabled. 133 121 */ 134 122 if (up->fcr & UART_FCR_ENABLE_FIFO) { 135 - lsr = p->serial_in(p, UART_LSR); 123 + lsr = serial_port_in(p, UART_LSR); 136 124 if (!(lsr & UART_LSR_DR)) 137 125 return; 138 126 } 139 127 140 - (void)p->serial_in(p, UART_RX); 128 + serial_port_in(p, UART_RX); 141 129 } 142 130 131 + /* 132 + * This function is being called as part of the uart_port::serial_out() 133 + * routine. Hence, it must not call serial_port_out() or serial_out() 134 + * against the modified registers here, i.e. LCR. 135 + */ 143 136 static void dw8250_check_lcr(struct uart_port *p, int offset, int value) 144 137 { 145 138 struct dw8250_data *d = to_dw8250_data(p->private_data); ··· 156 139 157 140 /* Make sure LCR write wasn't ignored */ 158 141 while (tries--) { 159 - unsigned int lcr = p->serial_in(p, offset); 142 + unsigned int lcr = serial_port_in(p, offset); 160 143 161 144 if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR)) 162 145 return; ··· 277 260 { 278 261 struct uart_8250_port *up = up_to_u8250p(p); 279 262 struct dw8250_data *d = to_dw8250_data(p->private_data); 280 - unsigned int iir = p->serial_in(p, UART_IIR); 263 + unsigned int iir = serial_port_in(p, UART_IIR); 281 264 bool rx_timeout = (iir & 0x3f) == UART_IIR_RX_TIMEOUT; 282 265 unsigned int quirks = d->pdata->quirks; 283 266 unsigned int status; ··· 298 281 status = serial_lsr_in(up); 299 282 300 283 if (!(status & (UART_LSR_DR | UART_LSR_BI))) 301 - (void) p->serial_in(p, UART_RX); 284 + serial_port_in(p, UART_RX); 302 285 303 286 uart_port_unlock_irqrestore(p, flags); 304 287 } ··· 320 303 321 304 if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) { 322 305 /* Clear the USR */ 323 - (void)p->serial_in(p, d->pdata->usr_reg); 306 + serial_port_in(p, d->pdata->usr_reg); 324 307 325 308 return 1; 326 309 } ··· 407 390 static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios) 408 391 { 409 392 struct uart_8250_port *up = up_to_u8250p(p); 410 - unsigned int mcr = p->serial_in(p, UART_MCR); 393 + unsigned int mcr = serial_port_in(p, UART_MCR); 411 394 412 395 if (up->capabilities & UART_CAP_IRDA) { 413 396 if (termios->c_line == N_IRDA) ··· 415 398 else 416 399 mcr &= ~DW_UART_MCR_SIRE; 417 400 418 - p->serial_out(p, UART_MCR, mcr); 401 + serial_port_out(p, UART_MCR, mcr); 419 402 } 420 403 serial8250_do_set_ldisc(p, termios); 421 404 } ··· 436 419 static bool dw8250_idma_filter(struct dma_chan *chan, void *param) 437 420 { 438 421 return param == chan->device->dev; 422 + } 423 + 424 + static void dw8250_setup_dma_filter(struct uart_port *p, struct dw8250_data *data) 425 + { 426 + /* Platforms with iDMA 64-bit */ 427 + if (platform_get_resource_byname(to_platform_device(p->dev), IORESOURCE_MEM, "lpss_priv")) { 428 + data->data.dma.rx_param = p->dev->parent; 429 + data->data.dma.tx_param = p->dev->parent; 430 + data->data.dma.fn = dw8250_idma_filter; 431 + } else { 432 + data->data.dma.fn = dw8250_fallback_dma_filter; 433 + } 439 434 } 440 435 441 436 static u32 dw8250_rzn1_get_dmacr_burst(int max_burst) ··· 488 459 489 460 static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) 490 461 { 491 - unsigned int quirks = data->pdata ? data->pdata->quirks : 0; 492 - u32 cpr_value = data->pdata ? data->pdata->cpr_value : 0; 462 + unsigned int quirks = data->pdata->quirks; 463 + u32 cpr_value = data->pdata->cpr_value; 493 464 494 465 if (quirks & DW_UART_QUIRK_CPR_VALUE) 495 466 data->data.cpr_value = cpr_value; ··· 520 491 p->serial_in = dw8250_serial_in32; 521 492 data->uart_16550_compatible = true; 522 493 } 523 - 524 - /* Platforms with iDMA 64-bit */ 525 - if (platform_get_resource_byname(to_platform_device(p->dev), 526 - IORESOURCE_MEM, "lpss_priv")) { 527 - data->data.dma.rx_param = p->dev->parent; 528 - data->data.dma.tx_param = p->dev->parent; 529 - data->data.dma.fn = dw8250_idma_filter; 530 - } 531 494 } 532 495 533 496 static void dw8250_reset_control_assert(void *data) ··· 541 520 return dev_err_probe(dev, -EINVAL, "no registers defined\n"); 542 521 543 522 spin_lock_init(&p->lock); 544 - p->handle_irq = dw8250_handle_irq; 545 523 p->pm = dw8250_do_pm; 546 524 p->type = PORT_8250; 547 525 p->flags = UPF_FIXED_PORT; ··· 552 532 if (!data) 553 533 return -ENOMEM; 554 534 555 - data->data.dma.fn = dw8250_fallback_dma_filter; 556 - data->pdata = device_get_match_data(p->dev); 557 535 p->private_data = &data->data; 558 - 559 - data->uart_16550_compatible = device_property_read_bool(dev, 560 - "snps,uart-16550-compatible"); 561 536 562 537 p->mapbase = regs->start; 563 538 p->mapsize = resource_size(regs); ··· 641 626 if (err) 642 627 return err; 643 628 644 - dw8250_quirks(p, data); 629 + data->uart_16550_compatible = device_property_read_bool(dev, "snps,uart-16550-compatible"); 630 + 631 + data->pdata = device_get_match_data(p->dev); 632 + if (data->pdata) 633 + dw8250_quirks(p, data); 645 634 646 635 /* If the Busy Functionality is not implemented, don't handle it */ 647 636 if (data->uart_16550_compatible) 648 637 p->handle_irq = NULL; 638 + else if (data->pdata) 639 + p->handle_irq = dw8250_handle_irq; 640 + 641 + dw8250_setup_dma_filter(p, data); 649 642 650 643 if (!data->skip_autocfg) 651 644 dw8250_setup_port(p);
+4 -4
drivers/tty/serial/8250/8250_fsl.c
··· 32 32 33 33 uart_port_lock_irqsave(&up->port, &flags); 34 34 35 - iir = port->serial_in(port, UART_IIR); 35 + iir = serial_port_in(port, UART_IIR); 36 36 if (iir & UART_IIR_NO_INT) { 37 37 uart_port_unlock_irqrestore(&up->port, flags); 38 38 return 0; ··· 54 54 if (unlikely((iir & UART_IIR_ID) == UART_IIR_RLSI && 55 55 (up->lsr_saved_flags & UART_LSR_BI))) { 56 56 up->lsr_saved_flags &= ~UART_LSR_BI; 57 - port->serial_in(port, UART_RX); 57 + serial_port_in(port, UART_RX); 58 58 uart_port_unlock_irqrestore(&up->port, flags); 59 59 return 1; 60 60 } 61 61 62 - lsr = orig_lsr = up->port.serial_in(&up->port, UART_LSR); 62 + lsr = orig_lsr = serial_port_in(port, UART_LSR); 63 63 64 64 /* Process incoming characters first */ 65 65 if ((lsr & (UART_LSR_DR | UART_LSR_BI)) && ··· 71 71 if ((orig_lsr & UART_LSR_OE) && (up->overrun_backoff_time_ms > 0)) { 72 72 unsigned long delay; 73 73 74 - up->ier = port->serial_in(port, UART_IER); 74 + up->ier = serial_port_in(port, UART_IER); 75 75 if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { 76 76 port->ops->stop_rx(port); 77 77 } else {
+461
drivers/tty/serial/8250/8250_ni.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * NI 16550 UART Driver 4 + * 5 + * The National Instruments (NI) 16550 is a UART that is compatible with the 6 + * TL16C550C and OX16C950B register interfaces, but has additional functions 7 + * for RS-485 transceiver control. This driver implements support for the 8 + * additional functionality on top of the standard serial8250 core. 9 + * 10 + * Copyright 2012-2023 National Instruments Corporation 11 + */ 12 + 13 + #include <linux/acpi.h> 14 + #include <linux/bitfield.h> 15 + #include <linux/device.h> 16 + #include <linux/io.h> 17 + #include <linux/init.h> 18 + #include <linux/module.h> 19 + #include <linux/property.h> 20 + #include <linux/clk.h> 21 + 22 + #include "8250.h" 23 + 24 + /* Extra bits in UART_ACR */ 25 + #define NI16550_ACR_AUTO_DTR_EN BIT(4) 26 + 27 + /* TFS - TX FIFO Size */ 28 + #define NI16550_TFS_OFFSET 0x0C 29 + /* RFS - RX FIFO Size */ 30 + #define NI16550_RFS_OFFSET 0x0D 31 + 32 + /* PMR - Port Mode Register */ 33 + #define NI16550_PMR_OFFSET 0x0E 34 + /* PMR[1:0] - Port Capabilities */ 35 + #define NI16550_PMR_CAP_MASK GENMASK(1, 0) 36 + #define NI16550_PMR_NOT_IMPL FIELD_PREP(NI16550_PMR_CAP_MASK, 0) /* not implemented */ 37 + #define NI16550_PMR_CAP_RS232 FIELD_PREP(NI16550_PMR_CAP_MASK, 1) /* RS-232 capable */ 38 + #define NI16550_PMR_CAP_RS485 FIELD_PREP(NI16550_PMR_CAP_MASK, 2) /* RS-485 capable */ 39 + #define NI16550_PMR_CAP_DUAL FIELD_PREP(NI16550_PMR_CAP_MASK, 3) /* dual-port */ 40 + /* PMR[4] - Interface Mode */ 41 + #define NI16550_PMR_MODE_MASK GENMASK(4, 4) 42 + #define NI16550_PMR_MODE_RS232 FIELD_PREP(NI16550_PMR_MODE_MASK, 0) /* currently 232 */ 43 + #define NI16550_PMR_MODE_RS485 FIELD_PREP(NI16550_PMR_MODE_MASK, 1) /* currently 485 */ 44 + 45 + /* PCR - Port Control Register */ 46 + /* 47 + * Wire Mode | Tx enabled? | Rx enabled? 48 + * ---------------|----------------------|-------------------------- 49 + * PCR_RS422 | Always | Always 50 + * PCR_ECHO_RS485 | When DTR asserted | Always 51 + * PCR_DTR_RS485 | When DTR asserted | Disabled when TX enabled 52 + * PCR_AUTO_RS485 | When data in TX FIFO | Disabled when TX enabled 53 + */ 54 + #define NI16550_PCR_OFFSET 0x0F 55 + #define NI16550_PCR_WIRE_MODE_MASK GENMASK(1, 0) 56 + #define NI16550_PCR_RS422 FIELD_PREP(NI16550_PCR_WIRE_MODE_MASK, 0) 57 + #define NI16550_PCR_ECHO_RS485 FIELD_PREP(NI16550_PCR_WIRE_MODE_MASK, 1) 58 + #define NI16550_PCR_DTR_RS485 FIELD_PREP(NI16550_PCR_WIRE_MODE_MASK, 2) 59 + #define NI16550_PCR_AUTO_RS485 FIELD_PREP(NI16550_PCR_WIRE_MODE_MASK, 3) 60 + #define NI16550_PCR_TXVR_ENABLE_BIT BIT(3) 61 + #define NI16550_PCR_RS485_TERMINATION_BIT BIT(6) 62 + 63 + /* flags for ni16550_device_info */ 64 + #define NI_HAS_PMR BIT(0) 65 + 66 + struct ni16550_device_info { 67 + u32 uartclk; 68 + u8 prescaler; 69 + u8 flags; 70 + }; 71 + 72 + struct ni16550_data { 73 + int line; 74 + struct clk *clk; 75 + }; 76 + 77 + static int ni16550_enable_transceivers(struct uart_port *port) 78 + { 79 + u8 pcr; 80 + 81 + pcr = port->serial_in(port, NI16550_PCR_OFFSET); 82 + pcr |= NI16550_PCR_TXVR_ENABLE_BIT; 83 + dev_dbg(port->dev, "enable transceivers: write pcr: 0x%02x\n", pcr); 84 + port->serial_out(port, NI16550_PCR_OFFSET, pcr); 85 + 86 + return 0; 87 + } 88 + 89 + static int ni16550_disable_transceivers(struct uart_port *port) 90 + { 91 + u8 pcr; 92 + 93 + pcr = port->serial_in(port, NI16550_PCR_OFFSET); 94 + pcr &= ~NI16550_PCR_TXVR_ENABLE_BIT; 95 + dev_dbg(port->dev, "disable transceivers: write pcr: 0x%02x\n", pcr); 96 + port->serial_out(port, NI16550_PCR_OFFSET, pcr); 97 + 98 + return 0; 99 + } 100 + 101 + static int ni16550_rs485_config(struct uart_port *port, 102 + struct ktermios *termios, 103 + struct serial_rs485 *rs485) 104 + { 105 + struct uart_8250_port *up = container_of(port, struct uart_8250_port, port); 106 + u8 pcr; 107 + 108 + pcr = serial_in(up, NI16550_PCR_OFFSET); 109 + pcr &= ~NI16550_PCR_WIRE_MODE_MASK; 110 + 111 + if ((rs485->flags & SER_RS485_MODE_RS422) || 112 + !(rs485->flags & SER_RS485_ENABLED)) { 113 + /* RS-422 */ 114 + pcr |= NI16550_PCR_RS422; 115 + up->acr &= ~NI16550_ACR_AUTO_DTR_EN; 116 + } else { 117 + /* RS-485 2-wire Auto */ 118 + pcr |= NI16550_PCR_AUTO_RS485; 119 + up->acr |= NI16550_ACR_AUTO_DTR_EN; 120 + } 121 + 122 + dev_dbg(port->dev, "config rs485: write pcr: 0x%02x, acr: %02x\n", pcr, up->acr); 123 + serial_out(up, NI16550_PCR_OFFSET, pcr); 124 + serial_icr_write(up, UART_ACR, up->acr); 125 + 126 + return 0; 127 + } 128 + 129 + static bool is_pmr_rs232_mode(struct uart_8250_port *up) 130 + { 131 + u8 pmr = serial_in(up, NI16550_PMR_OFFSET); 132 + u8 pmr_mode = pmr & NI16550_PMR_MODE_MASK; 133 + u8 pmr_cap = pmr & NI16550_PMR_CAP_MASK; 134 + 135 + /* 136 + * If the PMR is not implemented, then by default NI UARTs are 137 + * connected to RS-485 transceivers 138 + */ 139 + if (pmr_cap == NI16550_PMR_NOT_IMPL) 140 + return false; 141 + 142 + if (pmr_cap == NI16550_PMR_CAP_DUAL) 143 + /* 144 + * If the port is dual-mode capable, then read the mode bit 145 + * to know the current mode 146 + */ 147 + return pmr_mode == NI16550_PMR_MODE_RS232; 148 + /* 149 + * If it is not dual-mode capable, then decide based on the 150 + * capability 151 + */ 152 + return pmr_cap == NI16550_PMR_CAP_RS232; 153 + } 154 + 155 + static void ni16550_config_prescaler(struct uart_8250_port *up, 156 + u8 prescaler) 157 + { 158 + /* 159 + * Page in the Enhanced Mode Registers 160 + * Sets EFR[4] for Enhanced Mode. 161 + */ 162 + u8 lcr_value; 163 + u8 efr_value; 164 + 165 + lcr_value = serial_in(up, UART_LCR); 166 + serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 167 + 168 + efr_value = serial_in(up, UART_EFR); 169 + efr_value |= UART_EFR_ECB; 170 + 171 + serial_out(up, UART_EFR, efr_value); 172 + 173 + /* Page out the Enhanced Mode Registers */ 174 + serial_out(up, UART_LCR, lcr_value); 175 + 176 + /* Set prescaler to CPR register. */ 177 + serial_out(up, UART_SCR, UART_CPR); 178 + serial_out(up, UART_ICR, prescaler); 179 + } 180 + 181 + static const struct serial_rs485 ni16550_rs485_supported = { 182 + .flags = SER_RS485_ENABLED | SER_RS485_MODE_RS422 | SER_RS485_RTS_ON_SEND | 183 + SER_RS485_RTS_AFTER_SEND, 184 + /* 185 + * delay_rts_* and RX_DURING_TX are not supported. 186 + * 187 + * RTS_{ON,AFTER}_SEND are supported, but ignored; the transceiver 188 + * is connected in only one way and we don't need userspace to tell 189 + * us, but want to retain compatibility with applications that do. 190 + */ 191 + }; 192 + 193 + static void ni16550_rs485_setup(struct uart_port *port) 194 + { 195 + port->rs485_config = ni16550_rs485_config; 196 + port->rs485_supported = ni16550_rs485_supported; 197 + /* 198 + * The hardware comes up by default in 2-wire auto mode and we 199 + * set the flags to represent that 200 + */ 201 + port->rs485.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND; 202 + } 203 + 204 + static int ni16550_port_startup(struct uart_port *port) 205 + { 206 + int ret; 207 + 208 + ret = serial8250_do_startup(port); 209 + if (ret) 210 + return ret; 211 + 212 + return ni16550_enable_transceivers(port); 213 + } 214 + 215 + static void ni16550_port_shutdown(struct uart_port *port) 216 + { 217 + ni16550_disable_transceivers(port); 218 + 219 + serial8250_do_shutdown(port); 220 + } 221 + 222 + static int ni16550_get_regs(struct platform_device *pdev, 223 + struct uart_port *port) 224 + { 225 + struct resource *regs; 226 + 227 + regs = platform_get_resource(pdev, IORESOURCE_IO, 0); 228 + if (regs) { 229 + port->iotype = UPIO_PORT; 230 + port->iobase = regs->start; 231 + 232 + return 0; 233 + } 234 + 235 + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 236 + if (regs) { 237 + port->iotype = UPIO_MEM; 238 + port->mapbase = regs->start; 239 + port->mapsize = resource_size(regs); 240 + port->flags |= UPF_IOREMAP; 241 + 242 + port->membase = devm_ioremap(&pdev->dev, port->mapbase, 243 + port->mapsize); 244 + if (!port->membase) 245 + return -ENOMEM; 246 + 247 + return 0; 248 + } 249 + 250 + dev_err(&pdev->dev, "no registers defined\n"); 251 + return -EINVAL; 252 + } 253 + 254 + /* 255 + * Very old implementations don't have the TFS or RFS registers 256 + * defined, so we may read all-0s or all-1s. For such devices, 257 + * assume a FIFO size of 128. 258 + */ 259 + static u8 ni16550_read_fifo_size(struct uart_8250_port *uart, int reg) 260 + { 261 + u8 value = serial_in(uart, reg); 262 + 263 + if (value == 0x00 || value == 0xFF) 264 + return 128; 265 + 266 + return value; 267 + } 268 + 269 + static void ni16550_set_mctrl(struct uart_port *port, unsigned int mctrl) 270 + { 271 + struct uart_8250_port *up = up_to_u8250p(port); 272 + 273 + up->mcr |= UART_MCR_CLKSEL; 274 + serial8250_do_set_mctrl(port, mctrl); 275 + } 276 + 277 + static int ni16550_probe(struct platform_device *pdev) 278 + { 279 + const struct ni16550_device_info *info; 280 + struct device *dev = &pdev->dev; 281 + struct uart_8250_port uart = {}; 282 + unsigned int txfifosz, rxfifosz; 283 + unsigned int prescaler = 0; 284 + struct ni16550_data *data; 285 + const char *portmode; 286 + bool rs232_property; 287 + int ret; 288 + int irq; 289 + 290 + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 291 + if (!data) 292 + return -ENOMEM; 293 + 294 + spin_lock_init(&uart.port.lock); 295 + 296 + irq = platform_get_irq(pdev, 0); 297 + if (irq < 0) 298 + return irq; 299 + 300 + ret = ni16550_get_regs(pdev, &uart.port); 301 + if (ret < 0) 302 + return ret; 303 + 304 + /* early setup so that serial_in()/serial_out() work */ 305 + serial8250_set_defaults(&uart); 306 + 307 + info = device_get_match_data(dev); 308 + 309 + uart.port.dev = dev; 310 + uart.port.irq = irq; 311 + uart.port.irqflags = IRQF_SHARED; 312 + uart.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF 313 + | UPF_FIXED_PORT | UPF_FIXED_TYPE; 314 + uart.port.startup = ni16550_port_startup; 315 + uart.port.shutdown = ni16550_port_shutdown; 316 + 317 + /* 318 + * Hardware instantiation of FIFO sizes are held in registers. 319 + */ 320 + txfifosz = ni16550_read_fifo_size(&uart, NI16550_TFS_OFFSET); 321 + rxfifosz = ni16550_read_fifo_size(&uart, NI16550_RFS_OFFSET); 322 + 323 + dev_dbg(dev, "NI 16550 has TX FIFO size %u, RX FIFO size %u\n", 324 + txfifosz, rxfifosz); 325 + 326 + uart.port.type = PORT_16550A; 327 + uart.port.fifosize = txfifosz; 328 + uart.tx_loadsz = txfifosz; 329 + uart.fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10; 330 + uart.capabilities = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR; 331 + 332 + /* 333 + * Declaration of the base clock frequency can come from one of: 334 + * - static declaration in this driver (for older ACPI IDs) 335 + * - a "clock-frquency" ACPI 336 + */ 337 + if (info->uartclk) 338 + uart.port.uartclk = info->uartclk; 339 + if (device_property_read_u32(dev, "clock-frequency", 340 + &uart.port.uartclk)) { 341 + data->clk = devm_clk_get_enabled(dev, NULL); 342 + if (!IS_ERR(data->clk)) 343 + uart.port.uartclk = clk_get_rate(data->clk); 344 + } 345 + 346 + if (!uart.port.uartclk) { 347 + dev_err(dev, "unable to determine clock frequency!\n"); 348 + ret = -ENODEV; 349 + goto err; 350 + } 351 + 352 + if (info->prescaler) 353 + prescaler = info->prescaler; 354 + device_property_read_u32(dev, "clock-prescaler", &prescaler); 355 + 356 + if (prescaler != 0) { 357 + uart.port.set_mctrl = ni16550_set_mctrl; 358 + ni16550_config_prescaler(&uart, (u8)prescaler); 359 + } 360 + 361 + /* 362 + * The determination of whether or not this is an RS-485 or RS-232 port 363 + * can come from the PMR (if present), otherwise we're solely an RS-485 364 + * port. 365 + * 366 + * This is a device-specific property, and there are old devices in the 367 + * field using "transceiver" as an ACPI property, so we have to check 368 + * for that as well. 369 + */ 370 + if (!device_property_read_string(dev, "transceiver", &portmode)) { 371 + rs232_property = strncmp(portmode, "RS-232", 6) == 0; 372 + 373 + dev_dbg(dev, "port is in %s mode (via device property)\n", 374 + rs232_property ? "RS-232" : "RS-485"); 375 + } else if (info->flags & NI_HAS_PMR) { 376 + rs232_property = is_pmr_rs232_mode(&uart); 377 + 378 + dev_dbg(dev, "port is in %s mode (via PMR)\n", 379 + rs232_property ? "RS-232" : "RS-485"); 380 + } else { 381 + rs232_property = 0; 382 + 383 + dev_dbg(dev, "port is fixed as RS-485\n"); 384 + } 385 + 386 + if (!rs232_property) { 387 + /* 388 + * Neither the 'transceiver' property nor the PMR indicate 389 + * that this is an RS-232 port, so it must be an RS-485 one. 390 + */ 391 + ni16550_rs485_setup(&uart.port); 392 + } 393 + 394 + ret = serial8250_register_8250_port(&uart); 395 + if (ret < 0) 396 + goto err; 397 + data->line = ret; 398 + 399 + platform_set_drvdata(pdev, data); 400 + return 0; 401 + 402 + err: 403 + return ret; 404 + } 405 + 406 + static void ni16550_remove(struct platform_device *pdev) 407 + { 408 + struct ni16550_data *data = platform_get_drvdata(pdev); 409 + 410 + serial8250_unregister_port(data->line); 411 + } 412 + 413 + #ifdef CONFIG_ACPI 414 + /* NI 16550 RS-485 Interface */ 415 + static const struct ni16550_device_info nic7750 = { 416 + .uartclk = 33333333, 417 + }; 418 + 419 + /* NI CVS-145x RS-485 Interface */ 420 + static const struct ni16550_device_info nic7772 = { 421 + .uartclk = 1843200, 422 + .flags = NI_HAS_PMR, 423 + }; 424 + 425 + /* NI cRIO-904x RS-485 Interface */ 426 + static const struct ni16550_device_info nic792b = { 427 + /* Sets UART clock rate to 22.222 MHz with 1.125 prescale */ 428 + .uartclk = 22222222, 429 + .prescaler = 0x09, 430 + }; 431 + 432 + /* NI sbRIO 96x8 RS-232/485 Interfaces */ 433 + static const struct ni16550_device_info nic7a69 = { 434 + /* Set UART clock rate to 29.629 MHz with 1.125 prescale */ 435 + .uartclk = 29629629, 436 + .prescaler = 0x09, 437 + }; 438 + static const struct acpi_device_id ni16550_acpi_match[] = { 439 + { "NIC7750", (kernel_ulong_t)&nic7750 }, 440 + { "NIC7772", (kernel_ulong_t)&nic7772 }, 441 + { "NIC792B", (kernel_ulong_t)&nic792b }, 442 + { "NIC7A69", (kernel_ulong_t)&nic7a69 }, 443 + { }, 444 + }; 445 + MODULE_DEVICE_TABLE(acpi, ni16550_acpi_match); 446 + #endif 447 + 448 + static struct platform_driver ni16550_driver = { 449 + .driver = { 450 + .name = "ni16550", 451 + .acpi_match_table = ACPI_PTR(ni16550_acpi_match), 452 + }, 453 + .probe = ni16550_probe, 454 + .remove = ni16550_remove, 455 + }; 456 + 457 + module_platform_driver(ni16550_driver); 458 + 459 + MODULE_AUTHOR("Emerson Electric Co."); 460 + MODULE_DESCRIPTION("NI 16550 Driver"); 461 + MODULE_LICENSE("GPL");
+1 -1
drivers/tty/serial/8250/8250_omap.c
··· 692 692 693 693 /* Synchronize UART_IER access against the console. */ 694 694 uart_port_lock(port); 695 - up->ier = port->serial_in(port, UART_IER); 695 + up->ier = serial_port_in(port, UART_IER); 696 696 if (up->ier & (UART_IER_RLSI | UART_IER_RDI)) { 697 697 port->ops->stop_rx(port); 698 698 } else {
+46
drivers/tty/serial/8250/8250_pci.c
··· 2728 2728 .setup = pci_oxsemi_tornado_setup, 2729 2729 }, 2730 2730 { 2731 + .vendor = PCI_VENDOR_ID_INTASHIELD, 2732 + .device = 0x4026, 2733 + .subvendor = PCI_ANY_ID, 2734 + .subdevice = PCI_ANY_ID, 2735 + .init = pci_oxsemi_tornado_init, 2736 + .setup = pci_oxsemi_tornado_setup, 2737 + }, 2738 + { 2739 + .vendor = PCI_VENDOR_ID_INTASHIELD, 2740 + .device = 0x4021, 2741 + .subvendor = PCI_ANY_ID, 2742 + .subdevice = PCI_ANY_ID, 2743 + .init = pci_oxsemi_tornado_init, 2744 + .setup = pci_oxsemi_tornado_setup, 2745 + }, 2746 + { 2731 2747 .vendor = PCI_VENDOR_ID_INTEL, 2732 2748 .device = 0x8811, 2733 2749 .subvendor = PCI_ANY_ID, ··· 5269 5253 PCI_ANY_ID, PCI_ANY_ID, 5270 5254 0, 0, 5271 5255 pbn_b2_2_115200 }, 5256 + { PCI_VENDOR_ID_INTASHIELD, 0x0BA2, 5257 + PCI_ANY_ID, PCI_ANY_ID, 5258 + 0, 0, 5259 + pbn_b2_2_115200 }, 5260 + { PCI_VENDOR_ID_INTASHIELD, 0x0BA3, 5261 + PCI_ANY_ID, PCI_ANY_ID, 5262 + 0, 0, 5263 + pbn_b2_2_115200 }, 5272 5264 /* 5273 5265 * Brainboxes UC-235/246 5274 5266 */ ··· 5394 5370 * Brainboxes UC-368 5395 5371 */ 5396 5372 { PCI_VENDOR_ID_INTASHIELD, 0x0C41, 5373 + PCI_ANY_ID, PCI_ANY_ID, 5374 + 0, 0, 5375 + pbn_b2_4_115200 }, 5376 + { PCI_VENDOR_ID_INTASHIELD, 0x0C42, 5377 + PCI_ANY_ID, PCI_ANY_ID, 5378 + 0, 0, 5379 + pbn_b2_4_115200 }, 5380 + { PCI_VENDOR_ID_INTASHIELD, 0x0C43, 5397 5381 PCI_ANY_ID, PCI_ANY_ID, 5398 5382 0, 0, 5399 5383 pbn_b2_4_115200 }, ··· 5628 5596 0, 0, 5629 5597 pbn_b0_1_115200 }, 5630 5598 { PCI_VENDOR_ID_INTASHIELD, 0x4017, 5599 + PCI_ANY_ID, PCI_ANY_ID, 5600 + 0, 0, 5601 + pbn_oxsemi_1_15625000 }, 5602 + /* 5603 + * Brainboxes XC-235 5604 + */ 5605 + { PCI_VENDOR_ID_INTASHIELD, 0x4026, 5606 + PCI_ANY_ID, PCI_ANY_ID, 5607 + 0, 0, 5608 + pbn_oxsemi_1_15625000 }, 5609 + /* 5610 + * Brainboxes XC-475 5611 + */ 5612 + { PCI_VENDOR_ID_INTASHIELD, 0x4021, 5631 5613 PCI_ANY_ID, PCI_ANY_ID, 5632 5614 0, 0, 5633 5615 pbn_oxsemi_1_15625000 },
+27 -34
drivers/tty/serial/8250/8250_port.c
··· 1678 1678 if (up->bugs & UART_BUG_NOMSR) 1679 1679 return; 1680 1680 1681 - mctrl_gpio_disable_ms(up->gpios); 1681 + mctrl_gpio_disable_ms_no_sync(up->gpios); 1682 1682 1683 1683 up->ier &= ~UART_IER_MSI; 1684 1684 serial_port_out(port, UART_IER, up->ier); ··· 2406 2406 * test if we receive TX irq. This way, we'll never enable 2407 2407 * UART_BUG_TXEN. 2408 2408 */ 2409 - if (up->port.quirks & UPQ_NO_TXEN_TEST) 2410 - goto dont_test_tx_en; 2409 + if (!(up->port.quirks & UPQ_NO_TXEN_TEST)) { 2410 + /* 2411 + * Do a quick test to see if we receive an interrupt when we 2412 + * enable the TX irq. 2413 + */ 2414 + serial_port_out(port, UART_IER, UART_IER_THRI); 2415 + lsr = serial_port_in(port, UART_LSR); 2416 + iir = serial_port_in(port, UART_IIR); 2417 + serial_port_out(port, UART_IER, 0); 2411 2418 2412 - /* 2413 - * Do a quick test to see if we receive an interrupt when we enable 2414 - * the TX irq. 2415 - */ 2416 - serial_port_out(port, UART_IER, UART_IER_THRI); 2417 - lsr = serial_port_in(port, UART_LSR); 2418 - iir = serial_port_in(port, UART_IIR); 2419 - serial_port_out(port, UART_IER, 0); 2420 - 2421 - if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) { 2422 - if (!(up->bugs & UART_BUG_TXEN)) { 2423 - up->bugs |= UART_BUG_TXEN; 2424 - dev_dbg(port->dev, "enabling bad tx status workarounds\n"); 2419 + if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) { 2420 + if (!(up->bugs & UART_BUG_TXEN)) { 2421 + up->bugs |= UART_BUG_TXEN; 2422 + dev_dbg(port->dev, "enabling bad tx status workarounds\n"); 2423 + } 2424 + } else { 2425 + up->bugs &= ~UART_BUG_TXEN; 2425 2426 } 2426 - } else { 2427 - up->bugs &= ~UART_BUG_TXEN; 2428 2427 } 2429 2428 2430 - dont_test_tx_en: 2431 2429 uart_port_unlock_irqrestore(port, flags); 2432 2430 2433 2431 /* ··· 2966 2968 { 2967 2969 unsigned int size = serial8250_port_size(up); 2968 2970 struct uart_port *port = &up->port; 2969 - int ret = 0; 2970 2971 2971 2972 switch (port->iotype) { 2972 2973 case UPIO_AU: ··· 2974 2977 case UPIO_MEM32BE: 2975 2978 case UPIO_MEM16: 2976 2979 case UPIO_MEM: 2977 - if (!port->mapbase) { 2978 - ret = -EINVAL; 2979 - break; 2980 - } 2980 + if (!port->mapbase) 2981 + return -EINVAL; 2981 2982 2982 - if (!request_mem_region(port->mapbase, size, "serial")) { 2983 - ret = -EBUSY; 2984 - break; 2985 - } 2983 + if (!request_mem_region(port->mapbase, size, "serial")) 2984 + return -EBUSY; 2986 2985 2987 2986 if (port->flags & UPF_IOREMAP) { 2988 2987 port->membase = ioremap(port->mapbase, size); 2989 2988 if (!port->membase) { 2990 2989 release_mem_region(port->mapbase, size); 2991 - ret = -ENOMEM; 2990 + return -ENOMEM; 2992 2991 } 2993 2992 } 2994 - break; 2995 - 2993 + return 0; 2996 2994 case UPIO_HUB6: 2997 2995 case UPIO_PORT: 2998 2996 if (!request_region(port->iobase, size, "serial")) 2999 - ret = -EBUSY; 3000 - break; 2997 + return -EBUSY; 2998 + return 0; 3001 2999 } 3002 - return ret; 3000 + 3001 + return 0; 3003 3002 } 3004 3003 3005 3004 static void serial8250_release_std_resource(struct uart_8250_port *up)
+9 -12
drivers/tty/serial/8250/8250_rsa.c
··· 16 16 17 17 static int rsa8250_request_resource(struct uart_8250_port *up) 18 18 { 19 - unsigned long start = UART_RSA_BASE << up->port.regshift; 20 - unsigned int size = 8 << up->port.regshift; 21 19 struct uart_port *port = &up->port; 22 - int ret = -EINVAL; 20 + unsigned long start = UART_RSA_BASE << port->regshift; 21 + unsigned int size = 8 << port->regshift; 23 22 24 23 switch (port->iotype) { 25 24 case UPIO_HUB6: 26 25 case UPIO_PORT: 27 26 start += port->iobase; 28 - if (request_region(start, size, "serial-rsa")) 29 - ret = 0; 30 - else 31 - ret = -EBUSY; 32 - break; 27 + if (!request_region(start, size, "serial-rsa")) 28 + return -EBUSY; 29 + return 0; 30 + default: 31 + return -EINVAL; 33 32 } 34 - 35 - return ret; 36 33 } 37 34 38 35 static void rsa8250_release_resource(struct uart_8250_port *up) 39 36 { 40 - unsigned long offset = UART_RSA_BASE << up->port.regshift; 41 - unsigned int size = 8 << up->port.regshift; 42 37 struct uart_port *port = &up->port; 38 + unsigned long offset = UART_RSA_BASE << port->regshift; 39 + unsigned int size = 8 << port->regshift; 43 40 44 41 switch (port->iotype) { 45 42 case UPIO_HUB6:
+13
drivers/tty/serial/8250/Kconfig
··· 569 569 including DMA support and high accuracy BAUD rates, say 570 570 Y to this option. If unsure, say N. 571 571 572 + config SERIAL_8250_NI 573 + tristate "NI 16550 based serial port" 574 + depends on SERIAL_8250 575 + depends on (X86 && ACPI) || COMPILE_TEST 576 + help 577 + This driver supports the integrated serial ports on National 578 + Instruments (NI) controller hardware. This is required for all NI 579 + controller models with onboard RS-485 or dual-mode RS-485/RS-232 580 + ports. 581 + 582 + To compile this driver as a module, choose M here: the module 583 + will be called 8250_ni. 584 + 572 585 config SERIAL_OF_PLATFORM 573 586 tristate "Devicetree based probing for 8250 ports" 574 587 depends on SERIAL_8250 && OF
+1
drivers/tty/serial/8250/Makefile
··· 40 40 obj-$(CONFIG_SERIAL_8250_MEN_MCB) += 8250_men_mcb.o 41 41 obj-$(CONFIG_SERIAL_8250_MID) += 8250_mid.o 42 42 obj-$(CONFIG_SERIAL_8250_MT6577) += 8250_mtk.o 43 + obj-$(CONFIG_SERIAL_8250_NI) += 8250_ni.o 43 44 obj-$(CONFIG_SERIAL_OF_PLATFORM) += 8250_of.o 44 45 obj-$(CONFIG_SERIAL_8250_OMAP) += 8250_omap.o 45 46 obj-$(CONFIG_SERIAL_8250_PARISC) += 8250_parisc.o
+23 -19
drivers/tty/serial/Kconfig
··· 179 179 180 180 Say Y if you have an external 8250/16C550 UART. If unsure, say N. 181 181 182 - config SERIAL_KGDB_NMI 183 - bool "Serial console over KGDB NMI debugger port" 184 - depends on KGDB_SERIAL_CONSOLE 185 - help 186 - This special driver allows you to temporary use NMI debugger port 187 - as a normal console (assuming that the port is attached to KGDB). 188 - 189 - Unlike KDB's disable_nmi command, with this driver you are always 190 - able to go back to the debugger using KGDB escape sequence ($3#33). 191 - This is because this console driver processes the input in NMI 192 - context, and thus is able to intercept the magic sequence. 193 - 194 - Note that since the console interprets input and uses polling 195 - communication methods, for things like PPP you still must fully 196 - detach debugger port from the KGDB NMI (i.e. disable_nmi), and 197 - use raw console. 198 - 199 - If unsure, say N. 200 - 201 182 config SERIAL_MESON 202 183 tristate "Meson serial port support" 203 184 depends on ARCH_MESON || COMPILE_TEST ··· 284 303 system console (the system console is the device which receives all 285 304 kernel messages and warnings and which allows logins in single user 286 305 mode). 306 + 307 + If unsure, say Y. 308 + 309 + config SERIAL_TEGRA_UTC 310 + tristate "NVIDIA Tegra UART Trace Controller" 311 + depends on ARCH_TEGRA || COMPILE_TEST 312 + select SERIAL_CORE 313 + help 314 + Support for Tegra UTC (UART Trace controller) client serial port. 315 + 316 + UTC is a HW based serial port that allows multiplexing multiple data 317 + streams of up to 16 UTC clients into a single hardware serial port. 318 + 319 + config SERIAL_TEGRA_UTC_CONSOLE 320 + bool "Support for console on a Tegra UTC serial port" 321 + depends on SERIAL_TEGRA_UTC 322 + select SERIAL_CORE_CONSOLE 323 + default SERIAL_TEGRA_UTC 324 + help 325 + If you say Y here, it will be possible to use a Tegra UTC client as 326 + the system console (the system console is the device which receives 327 + all kernel messages and warnings and which allows logins in single 328 + user mode). 287 329 288 330 If unsure, say Y. 289 331
+1 -1
drivers/tty/serial/Makefile
··· 86 86 obj-$(CONFIG_SERIAL_SUNPLUS) += sunplus-uart.o 87 87 obj-$(CONFIG_SERIAL_TEGRA) += serial-tegra.o 88 88 obj-$(CONFIG_SERIAL_TEGRA_TCU) += tegra-tcu.o 89 + obj-$(CONFIG_SERIAL_TEGRA_UTC) += tegra-utc.o 89 90 obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o 90 91 obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o 91 92 obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o ··· 97 96 # GPIOLIB helpers for modem control lines 98 97 obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o 99 98 100 - obj-$(CONFIG_SERIAL_KGDB_NMI) += kgdb_nmi.o 101 99 obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o 102 100 obj-$(CONFIG_SERIAL_NUVOTON_MA35D1) += ma35d1_serial.o
+100 -49
drivers/tty/serial/amba-pl011.c
··· 272 272 enum pl011_rs485_tx_state rs485_tx_state; 273 273 struct hrtimer trigger_start_tx; 274 274 struct hrtimer trigger_stop_tx; 275 + bool console_line_ended; 275 276 #ifdef CONFIG_DMA_ENGINE 276 277 /* DMA stuff */ 277 278 unsigned int dmacr; /* dma control reg */ ··· 2367 2366 while (pl011_read(uap, REG_FR) & UART01x_FR_TXFF) 2368 2367 cpu_relax(); 2369 2368 pl011_write(ch, uap, REG_DR); 2370 - } 2371 - 2372 - static void 2373 - pl011_console_write(struct console *co, const char *s, unsigned int count) 2374 - { 2375 - struct uart_amba_port *uap = amba_ports[co->index]; 2376 - unsigned int old_cr = 0, new_cr; 2377 - unsigned long flags; 2378 - int locked = 1; 2379 - 2380 - clk_enable(uap->clk); 2381 - 2382 - if (oops_in_progress) 2383 - locked = uart_port_trylock_irqsave(&uap->port, &flags); 2384 - else 2385 - uart_port_lock_irqsave(&uap->port, &flags); 2386 - 2387 - /* 2388 - * First save the CR then disable the interrupts 2389 - */ 2390 - if (!uap->vendor->always_enabled) { 2391 - old_cr = pl011_read(uap, REG_CR); 2392 - new_cr = old_cr & ~UART011_CR_CTSEN; 2393 - new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE; 2394 - pl011_write(new_cr, uap, REG_CR); 2395 - } 2396 - 2397 - uart_console_write(&uap->port, s, count, pl011_console_putchar); 2398 - 2399 - /* 2400 - * Finally, wait for transmitter to become empty and restore the 2401 - * TCR. Allow feature register bits to be inverted to work around 2402 - * errata. 2403 - */ 2404 - while ((pl011_read(uap, REG_FR) ^ uap->vendor->inv_fr) 2405 - & uap->vendor->fr_busy) 2406 - cpu_relax(); 2407 - if (!uap->vendor->always_enabled) 2408 - pl011_write(old_cr, uap, REG_CR); 2409 - 2410 - if (locked) 2411 - uart_port_unlock_irqrestore(&uap->port, flags); 2412 - 2413 - clk_disable(uap->clk); 2369 + uap->console_line_ended = (ch == '\n'); 2414 2370 } 2415 2371 2416 2372 static void pl011_console_get_options(struct uart_amba_port *uap, int *baud, ··· 2429 2471 ret = clk_prepare(uap->clk); 2430 2472 if (ret) 2431 2473 return ret; 2474 + 2475 + uap->console_line_ended = true; 2432 2476 2433 2477 if (dev_get_platdata(uap->port.dev)) { 2434 2478 struct amba_pl011_data *plat; ··· 2515 2555 return -ENODEV; 2516 2556 } 2517 2557 2558 + static void 2559 + pl011_console_write_atomic(struct console *co, struct nbcon_write_context *wctxt) 2560 + { 2561 + struct uart_amba_port *uap = amba_ports[co->index]; 2562 + unsigned int old_cr = 0; 2563 + 2564 + if (!nbcon_enter_unsafe(wctxt)) 2565 + return; 2566 + 2567 + clk_enable(uap->clk); 2568 + 2569 + if (!uap->vendor->always_enabled) { 2570 + old_cr = pl011_read(uap, REG_CR); 2571 + pl011_write((old_cr & ~UART011_CR_CTSEN) | (UART01x_CR_UARTEN | UART011_CR_TXE), 2572 + uap, REG_CR); 2573 + } 2574 + 2575 + if (!uap->console_line_ended) 2576 + uart_console_write(&uap->port, "\n", 1, pl011_console_putchar); 2577 + uart_console_write(&uap->port, wctxt->outbuf, wctxt->len, pl011_console_putchar); 2578 + 2579 + while ((pl011_read(uap, REG_FR) ^ uap->vendor->inv_fr) & uap->vendor->fr_busy) 2580 + cpu_relax(); 2581 + 2582 + if (!uap->vendor->always_enabled) 2583 + pl011_write(old_cr, uap, REG_CR); 2584 + 2585 + clk_disable(uap->clk); 2586 + 2587 + nbcon_exit_unsafe(wctxt); 2588 + } 2589 + 2590 + static void 2591 + pl011_console_write_thread(struct console *co, struct nbcon_write_context *wctxt) 2592 + { 2593 + struct uart_amba_port *uap = amba_ports[co->index]; 2594 + unsigned int old_cr = 0; 2595 + 2596 + if (!nbcon_enter_unsafe(wctxt)) 2597 + return; 2598 + 2599 + clk_enable(uap->clk); 2600 + 2601 + if (!uap->vendor->always_enabled) { 2602 + old_cr = pl011_read(uap, REG_CR); 2603 + pl011_write((old_cr & ~UART011_CR_CTSEN) | (UART01x_CR_UARTEN | UART011_CR_TXE), 2604 + uap, REG_CR); 2605 + } 2606 + 2607 + if (nbcon_exit_unsafe(wctxt)) { 2608 + int i; 2609 + unsigned int len = READ_ONCE(wctxt->len); 2610 + 2611 + for (i = 0; i < len; i++) { 2612 + if (!nbcon_enter_unsafe(wctxt)) 2613 + break; 2614 + uart_console_write(&uap->port, wctxt->outbuf + i, 1, pl011_console_putchar); 2615 + if (!nbcon_exit_unsafe(wctxt)) 2616 + break; 2617 + } 2618 + } 2619 + 2620 + while (!nbcon_enter_unsafe(wctxt)) 2621 + nbcon_reacquire_nobuf(wctxt); 2622 + 2623 + while ((pl011_read(uap, REG_FR) ^ uap->vendor->inv_fr) & uap->vendor->fr_busy) 2624 + cpu_relax(); 2625 + 2626 + if (!uap->vendor->always_enabled) 2627 + pl011_write(old_cr, uap, REG_CR); 2628 + 2629 + clk_disable(uap->clk); 2630 + 2631 + nbcon_exit_unsafe(wctxt); 2632 + } 2633 + 2634 + static void 2635 + pl011_console_device_lock(struct console *co, unsigned long *flags) 2636 + { 2637 + __uart_port_lock_irqsave(&amba_ports[co->index]->port, flags); 2638 + } 2639 + 2640 + static void 2641 + pl011_console_device_unlock(struct console *co, unsigned long flags) 2642 + { 2643 + __uart_port_unlock_irqrestore(&amba_ports[co->index]->port, flags); 2644 + } 2645 + 2518 2646 static struct uart_driver amba_reg; 2519 2647 static struct console amba_console = { 2520 2648 .name = "ttyAMA", 2521 - .write = pl011_console_write, 2522 2649 .device = uart_console_device, 2523 2650 .setup = pl011_console_setup, 2524 2651 .match = pl011_console_match, 2525 - .flags = CON_PRINTBUFFER | CON_ANYTIME, 2652 + .write_atomic = pl011_console_write_atomic, 2653 + .write_thread = pl011_console_write_thread, 2654 + .device_lock = pl011_console_device_lock, 2655 + .device_unlock = pl011_console_device_unlock, 2656 + .flags = CON_PRINTBUFFER | CON_ANYTIME | CON_NBCON, 2526 2657 .index = -1, 2527 2658 .data = &amba_reg, 2528 2659 }; ··· 3051 3000 }; 3052 3001 MODULE_DEVICE_TABLE(of, sbsa_uart_of_match); 3053 3002 3054 - static const struct acpi_device_id __maybe_unused sbsa_uart_acpi_match[] = { 3003 + static const struct acpi_device_id sbsa_uart_acpi_match[] = { 3055 3004 { "ARMH0011", 0 }, 3056 3005 { "ARMHB000", 0 }, 3057 3006 {}, ··· 3064 3013 .driver = { 3065 3014 .name = "sbsa-uart", 3066 3015 .pm = &pl011_dev_pm_ops, 3067 - .of_match_table = of_match_ptr(sbsa_uart_of_match), 3068 - .acpi_match_table = ACPI_PTR(sbsa_uart_acpi_match), 3016 + .of_match_table = sbsa_uart_of_match, 3017 + .acpi_match_table = sbsa_uart_acpi_match, 3069 3018 .suppress_bind_attrs = IS_BUILTIN(CONFIG_SERIAL_AMBA_PL011), 3070 3019 }, 3071 3020 };
+1 -1
drivers/tty/serial/atmel_serial.c
··· 700 700 701 701 atmel_port->ms_irq_enabled = false; 702 702 703 - mctrl_gpio_disable_ms(atmel_port->gpios); 703 + mctrl_gpio_disable_ms_no_sync(atmel_port->gpios); 704 704 705 705 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) 706 706 idr |= ATMEL_US_CTSIC;
+249 -240
drivers/tty/serial/fsl_lpuart.c
··· 441 441 442 442 static void lpuart_stop_tx(struct uart_port *port) 443 443 { 444 - unsigned char temp; 444 + u8 cr2; 445 445 446 - temp = readb(port->membase + UARTCR2); 447 - temp &= ~(UARTCR2_TIE | UARTCR2_TCIE); 448 - writeb(temp, port->membase + UARTCR2); 446 + cr2 = readb(port->membase + UARTCR2); 447 + cr2 &= ~(UARTCR2_TIE | UARTCR2_TCIE); 448 + writeb(cr2, port->membase + UARTCR2); 449 449 } 450 450 451 451 static void lpuart32_stop_tx(struct uart_port *port) 452 452 { 453 - unsigned long temp; 453 + u32 ctrl; 454 454 455 - temp = lpuart32_read(port, UARTCTRL); 456 - temp &= ~(UARTCTRL_TIE | UARTCTRL_TCIE); 457 - lpuart32_write(port, temp, UARTCTRL); 455 + ctrl = lpuart32_read(port, UARTCTRL); 456 + ctrl &= ~(UARTCTRL_TIE | UARTCTRL_TCIE); 457 + lpuart32_write(port, ctrl, UARTCTRL); 458 458 } 459 459 460 460 static void lpuart_stop_rx(struct uart_port *port) 461 461 { 462 - unsigned char temp; 462 + u8 cr2; 463 463 464 - temp = readb(port->membase + UARTCR2); 465 - writeb(temp & ~UARTCR2_RE, port->membase + UARTCR2); 464 + cr2 = readb(port->membase + UARTCR2); 465 + writeb(cr2 & ~UARTCR2_RE, port->membase + UARTCR2); 466 466 } 467 467 468 468 static void lpuart32_stop_rx(struct uart_port *port) 469 469 { 470 - unsigned long temp; 470 + u32 ctrl; 471 471 472 - temp = lpuart32_read(port, UARTCTRL); 473 - lpuart32_write(port, temp & ~UARTCTRL_RE, UARTCTRL); 472 + ctrl = lpuart32_read(port, UARTCTRL); 473 + lpuart32_write(port, ctrl & ~UARTCTRL_RE, UARTCTRL); 474 474 } 475 475 476 476 static void lpuart_dma_tx(struct lpuart_port *sport) ··· 581 581 ret = dmaengine_slave_config(sport->dma_tx_chan, &dma_tx_sconfig); 582 582 583 583 if (ret) { 584 - dev_err(sport->port.dev, 584 + dev_err(port->dev, 585 585 "DMA slave config failed, err = %d\n", ret); 586 586 return ret; 587 587 } ··· 599 599 { 600 600 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 601 601 struct dma_chan *chan = sport->dma_tx_chan; 602 - u32 val; 602 + u32 fifo; 603 603 604 604 if (sport->lpuart_dma_tx_use) { 605 605 if (sport->dma_tx_in_progress) { ··· 611 611 } 612 612 613 613 if (lpuart_is_32(sport)) { 614 - val = lpuart32_read(&sport->port, UARTFIFO); 615 - val |= UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH; 616 - lpuart32_write(&sport->port, val, UARTFIFO); 614 + fifo = lpuart32_read(port, UARTFIFO); 615 + fifo |= UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH; 616 + lpuart32_write(port, fifo, UARTFIFO); 617 617 } else { 618 - val = readb(sport->port.membase + UARTCFIFO); 619 - val |= UARTCFIFO_TXFLUSH | UARTCFIFO_RXFLUSH; 620 - writeb(val, sport->port.membase + UARTCFIFO); 618 + fifo = readb(port->membase + UARTCFIFO); 619 + fifo |= UARTCFIFO_TXFLUSH | UARTCFIFO_RXFLUSH; 620 + writeb(fifo, port->membase + UARTCFIFO); 621 621 } 622 622 } 623 623 ··· 639 639 640 640 static int lpuart_poll_init(struct uart_port *port) 641 641 { 642 - struct lpuart_port *sport = container_of(port, 643 - struct lpuart_port, port); 644 642 unsigned long flags; 645 - unsigned char temp; 643 + u8 fifo; 646 644 647 - sport->port.fifosize = 0; 645 + port->fifosize = 0; 648 646 649 - uart_port_lock_irqsave(&sport->port, &flags); 647 + uart_port_lock_irqsave(port, &flags); 650 648 /* Disable Rx & Tx */ 651 - writeb(0, sport->port.membase + UARTCR2); 649 + writeb(0, port->membase + UARTCR2); 652 650 653 - temp = readb(sport->port.membase + UARTPFIFO); 651 + fifo = readb(port->membase + UARTPFIFO); 654 652 /* Enable Rx and Tx FIFO */ 655 - writeb(temp | UARTPFIFO_RXFE | UARTPFIFO_TXFE, 656 - sport->port.membase + UARTPFIFO); 653 + writeb(fifo | UARTPFIFO_RXFE | UARTPFIFO_TXFE, 654 + port->membase + UARTPFIFO); 657 655 658 656 /* flush Tx and Rx FIFO */ 659 657 writeb(UARTCFIFO_TXFLUSH | UARTCFIFO_RXFLUSH, 660 - sport->port.membase + UARTCFIFO); 658 + port->membase + UARTCFIFO); 661 659 662 660 /* explicitly clear RDRF */ 663 - if (readb(sport->port.membase + UARTSR1) & UARTSR1_RDRF) { 664 - readb(sport->port.membase + UARTDR); 665 - writeb(UARTSFIFO_RXUF, sport->port.membase + UARTSFIFO); 661 + if (readb(port->membase + UARTSR1) & UARTSR1_RDRF) { 662 + readb(port->membase + UARTDR); 663 + writeb(UARTSFIFO_RXUF, port->membase + UARTSFIFO); 666 664 } 667 665 668 - writeb(0, sport->port.membase + UARTTWFIFO); 669 - writeb(1, sport->port.membase + UARTRWFIFO); 666 + writeb(0, port->membase + UARTTWFIFO); 667 + writeb(1, port->membase + UARTRWFIFO); 670 668 671 669 /* Enable Rx and Tx */ 672 - writeb(UARTCR2_RE | UARTCR2_TE, sport->port.membase + UARTCR2); 673 - uart_port_unlock_irqrestore(&sport->port, flags); 670 + writeb(UARTCR2_RE | UARTCR2_TE, port->membase + UARTCR2); 671 + uart_port_unlock_irqrestore(port, flags); 674 672 675 673 return 0; 676 674 } ··· 691 693 static int lpuart32_poll_init(struct uart_port *port) 692 694 { 693 695 unsigned long flags; 694 - struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 695 - u32 temp; 696 + u32 fifo; 696 697 697 - sport->port.fifosize = 0; 698 + port->fifosize = 0; 698 699 699 - uart_port_lock_irqsave(&sport->port, &flags); 700 + uart_port_lock_irqsave(port, &flags); 700 701 701 702 /* Disable Rx & Tx */ 702 - lpuart32_write(&sport->port, 0, UARTCTRL); 703 + lpuart32_write(port, 0, UARTCTRL); 703 704 704 - temp = lpuart32_read(&sport->port, UARTFIFO); 705 + fifo = lpuart32_read(port, UARTFIFO); 705 706 706 707 /* Enable Rx and Tx FIFO */ 707 - lpuart32_write(&sport->port, temp | UARTFIFO_RXFE | UARTFIFO_TXFE, UARTFIFO); 708 + lpuart32_write(port, fifo | UARTFIFO_RXFE | UARTFIFO_TXFE, UARTFIFO); 708 709 709 710 /* flush Tx and Rx FIFO */ 710 - lpuart32_write(&sport->port, UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH, UARTFIFO); 711 + lpuart32_write(port, UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH, UARTFIFO); 711 712 712 713 /* explicitly clear RDRF */ 713 - if (lpuart32_read(&sport->port, UARTSTAT) & UARTSTAT_RDRF) { 714 - lpuart32_read(&sport->port, UARTDATA); 715 - lpuart32_write(&sport->port, UARTFIFO_RXUF, UARTFIFO); 714 + if (lpuart32_read(port, UARTSTAT) & UARTSTAT_RDRF) { 715 + lpuart32_read(port, UARTDATA); 716 + lpuart32_write(port, UARTFIFO_RXUF, UARTFIFO); 716 717 } 717 718 718 719 /* Enable Rx and Tx */ 719 - lpuart32_write(&sport->port, UARTCTRL_RE | UARTCTRL_TE, UARTCTRL); 720 - uart_port_unlock_irqrestore(&sport->port, flags); 720 + lpuart32_write(port, UARTCTRL_RE | UARTCTRL_TE, UARTCTRL); 721 + uart_port_unlock_irqrestore(port, flags); 721 722 722 723 return 0; 723 724 } ··· 749 752 static inline void lpuart32_transmit_buffer(struct lpuart_port *sport) 750 753 { 751 754 struct tty_port *tport = &sport->port.state->port; 752 - unsigned long txcnt; 755 + u32 txcnt; 753 756 unsigned char c; 754 757 755 758 if (sport->port.x_char) { ··· 786 789 { 787 790 struct lpuart_port *sport = container_of(port, 788 791 struct lpuart_port, port); 789 - unsigned char temp; 792 + u8 cr2; 790 793 791 - temp = readb(port->membase + UARTCR2); 792 - writeb(temp | UARTCR2_TIE, port->membase + UARTCR2); 794 + cr2 = readb(port->membase + UARTCR2); 795 + writeb(cr2 | UARTCR2_TIE, port->membase + UARTCR2); 793 796 794 797 if (sport->lpuart_dma_tx_use) { 795 798 if (!lpuart_stopped_or_empty(port)) ··· 803 806 static void lpuart32_start_tx(struct uart_port *port) 804 807 { 805 808 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 806 - unsigned long temp; 809 + u32 ctrl; 807 810 808 811 if (sport->lpuart_dma_tx_use) { 809 812 if (!lpuart_stopped_or_empty(port)) 810 813 lpuart_dma_tx(sport); 811 814 } else { 812 - temp = lpuart32_read(port, UARTCTRL); 813 - lpuart32_write(port, temp | UARTCTRL_TIE, UARTCTRL); 815 + ctrl = lpuart32_read(port, UARTCTRL); 816 + lpuart32_write(port, ctrl | UARTCTRL_TIE, UARTCTRL); 814 817 815 818 if (lpuart32_read(port, UARTSTAT) & UARTSTAT_TDRE) 816 819 lpuart32_transmit_buffer(sport); ··· 836 839 { 837 840 struct lpuart_port *sport = container_of(port, 838 841 struct lpuart_port, port); 839 - unsigned char sr1 = readb(port->membase + UARTSR1); 840 - unsigned char sfifo = readb(port->membase + UARTSFIFO); 842 + u8 sr1 = readb(port->membase + UARTSR1); 843 + u8 sfifo = readb(port->membase + UARTSFIFO); 841 844 842 845 if (sport->dma_tx_in_progress) 843 846 return 0; ··· 852 855 { 853 856 struct lpuart_port *sport = container_of(port, 854 857 struct lpuart_port, port); 855 - unsigned long stat = lpuart32_read(port, UARTSTAT); 856 - unsigned long sfifo = lpuart32_read(port, UARTFIFO); 857 - unsigned long ctrl = lpuart32_read(port, UARTCTRL); 858 + u32 stat = lpuart32_read(port, UARTSTAT); 859 + u32 sfifo = lpuart32_read(port, UARTFIFO); 860 + u32 ctrl = lpuart32_read(port, UARTCTRL); 858 861 859 862 if (sport->dma_tx_in_progress) 860 863 return 0; ··· 881 884 { 882 885 unsigned int flg, ignored = 0, overrun = 0; 883 886 struct tty_port *port = &sport->port.state->port; 884 - unsigned char rx, sr; 887 + u8 rx, sr; 885 888 886 889 uart_port_lock(&sport->port); 887 890 ··· 958 961 { 959 962 unsigned int flg, ignored = 0; 960 963 struct tty_port *port = &sport->port.state->port; 961 - unsigned long rx, sr; 964 + u32 rx, sr; 962 965 bool is_break; 963 966 964 967 uart_port_lock(&sport->port); ··· 1036 1039 static irqreturn_t lpuart_int(int irq, void *dev_id) 1037 1040 { 1038 1041 struct lpuart_port *sport = dev_id; 1039 - unsigned char sts; 1042 + u8 sts; 1040 1043 1041 1044 sts = readb(sport->port.membase + UARTSR1); 1042 1045 ··· 1110 1113 int count, copied; 1111 1114 1112 1115 if (lpuart_is_32(sport)) { 1113 - unsigned long sr = lpuart32_read(&sport->port, UARTSTAT); 1116 + u32 sr = lpuart32_read(&sport->port, UARTSTAT); 1114 1117 1115 1118 if (sr & (UARTSTAT_PE | UARTSTAT_FE)) { 1116 1119 /* Clear the error flags */ ··· 1122 1125 sport->port.icount.frame++; 1123 1126 } 1124 1127 } else { 1125 - unsigned char sr = readb(sport->port.membase + UARTSR1); 1128 + u8 sr = readb(sport->port.membase + UARTSR1); 1126 1129 1127 1130 if (sr & (UARTSR1_PE | UARTSR1_FE)) { 1128 - unsigned char cr2; 1131 + u8 cr2; 1129 1132 1130 1133 /* Disable receiver during this operation... */ 1131 1134 cr2 = readb(sport->port.membase + UARTCR2); ··· 1276 1279 static irqreturn_t lpuart32_int(int irq, void *dev_id) 1277 1280 { 1278 1281 struct lpuart_port *sport = dev_id; 1279 - unsigned long sts, rxcount; 1282 + u32 sts, rxcount; 1280 1283 1281 1284 sts = lpuart32_read(&sport->port, UARTSTAT); 1282 1285 rxcount = lpuart32_read(&sport->port, UARTWATER); ··· 1408 1411 dma_async_issue_pending(chan); 1409 1412 1410 1413 if (lpuart_is_32(sport)) { 1411 - unsigned long temp = lpuart32_read(&sport->port, UARTBAUD); 1414 + u32 baud = lpuart32_read(&sport->port, UARTBAUD); 1412 1415 1413 - lpuart32_write(&sport->port, temp | UARTBAUD_RDMAE, UARTBAUD); 1416 + lpuart32_write(&sport->port, baud | UARTBAUD_RDMAE, UARTBAUD); 1414 1417 1415 1418 if (sport->dma_idle_int) { 1416 - unsigned long ctrl = lpuart32_read(&sport->port, UARTCTRL); 1419 + u32 ctrl = lpuart32_read(&sport->port, UARTCTRL); 1417 1420 1418 1421 lpuart32_write(&sport->port, ctrl | UARTCTRL_ILIE, UARTCTRL); 1419 1422 } ··· 1446 1449 static int lpuart_config_rs485(struct uart_port *port, struct ktermios *termios, 1447 1450 struct serial_rs485 *rs485) 1448 1451 { 1449 - struct lpuart_port *sport = container_of(port, 1450 - struct lpuart_port, port); 1451 - 1452 - u8 modem = readb(sport->port.membase + UARTMODEM) & 1452 + u8 modem = readb(port->membase + UARTMODEM) & 1453 1453 ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE); 1454 - writeb(modem, sport->port.membase + UARTMODEM); 1454 + writeb(modem, port->membase + UARTMODEM); 1455 1455 1456 1456 if (rs485->flags & SER_RS485_ENABLED) { 1457 1457 /* Enable auto RS-485 RTS mode */ ··· 1466 1472 modem &= ~UARTMODEM_TXRTSPOL; 1467 1473 } 1468 1474 1469 - writeb(modem, sport->port.membase + UARTMODEM); 1475 + writeb(modem, port->membase + UARTMODEM); 1470 1476 return 0; 1471 1477 } 1472 1478 1473 1479 static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termios, 1474 1480 struct serial_rs485 *rs485) 1475 1481 { 1476 - struct lpuart_port *sport = container_of(port, 1477 - struct lpuart_port, port); 1478 - 1479 - unsigned long modem = lpuart32_read(&sport->port, UARTMODIR) 1482 + u32 modem = lpuart32_read(port, UARTMODIR) 1480 1483 & ~(UARTMODIR_TXRTSPOL | UARTMODIR_TXRTSE); 1481 - lpuart32_write(&sport->port, modem, UARTMODIR); 1484 + u32 ctrl; 1485 + 1486 + /* TXRTSE and TXRTSPOL only can be changed when transmitter is disabled. */ 1487 + ctrl = lpuart32_read(port, UARTCTRL); 1488 + if (ctrl & UARTCTRL_TE) { 1489 + /* wait for the transmit engine to complete */ 1490 + lpuart32_wait_bit_set(port, UARTSTAT, UARTSTAT_TC); 1491 + lpuart32_write(port, ctrl & ~UARTCTRL_TE, UARTCTRL); 1492 + 1493 + while (lpuart32_read(port, UARTCTRL) & UARTCTRL_TE) 1494 + cpu_relax(); 1495 + } 1496 + 1497 + lpuart32_write(port, modem, UARTMODIR); 1482 1498 1483 1499 if (rs485->flags & SER_RS485_ENABLED) { 1484 1500 /* Enable auto RS-485 RTS mode */ ··· 1506 1502 modem &= ~UARTMODIR_TXRTSPOL; 1507 1503 } 1508 1504 1509 - lpuart32_write(&sport->port, modem, UARTMODIR); 1505 + lpuart32_write(port, modem, UARTMODIR); 1506 + 1507 + if (ctrl & UARTCTRL_TE) 1508 + lpuart32_write(port, ctrl, UARTCTRL); 1509 + 1510 1510 return 0; 1511 1511 } 1512 1512 1513 1513 static unsigned int lpuart_get_mctrl(struct uart_port *port) 1514 1514 { 1515 1515 unsigned int mctrl = 0; 1516 - u8 reg; 1516 + u8 cr1; 1517 1517 1518 - reg = readb(port->membase + UARTCR1); 1519 - if (reg & UARTCR1_LOOPS) 1518 + cr1 = readb(port->membase + UARTCR1); 1519 + if (cr1 & UARTCR1_LOOPS) 1520 1520 mctrl |= TIOCM_LOOP; 1521 1521 1522 1522 return mctrl; ··· 1529 1521 static unsigned int lpuart32_get_mctrl(struct uart_port *port) 1530 1522 { 1531 1523 unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; 1532 - u32 reg; 1524 + u32 ctrl; 1533 1525 1534 - reg = lpuart32_read(port, UARTCTRL); 1535 - if (reg & UARTCTRL_LOOPS) 1526 + ctrl = lpuart32_read(port, UARTCTRL); 1527 + if (ctrl & UARTCTRL_LOOPS) 1536 1528 mctrl |= TIOCM_LOOP; 1537 1529 1538 1530 return mctrl; ··· 1540 1532 1541 1533 static void lpuart_set_mctrl(struct uart_port *port, unsigned int mctrl) 1542 1534 { 1543 - u8 reg; 1535 + u8 cr1; 1544 1536 1545 - reg = readb(port->membase + UARTCR1); 1537 + cr1 = readb(port->membase + UARTCR1); 1546 1538 1547 1539 /* for internal loopback we need LOOPS=1 and RSRC=0 */ 1548 - reg &= ~(UARTCR1_LOOPS | UARTCR1_RSRC); 1540 + cr1 &= ~(UARTCR1_LOOPS | UARTCR1_RSRC); 1549 1541 if (mctrl & TIOCM_LOOP) 1550 - reg |= UARTCR1_LOOPS; 1542 + cr1 |= UARTCR1_LOOPS; 1551 1543 1552 - writeb(reg, port->membase + UARTCR1); 1544 + writeb(cr1, port->membase + UARTCR1); 1553 1545 } 1554 1546 1555 1547 static void lpuart32_set_mctrl(struct uart_port *port, unsigned int mctrl) 1556 1548 { 1557 - u32 reg; 1549 + u32 ctrl; 1558 1550 1559 - reg = lpuart32_read(port, UARTCTRL); 1551 + ctrl = lpuart32_read(port, UARTCTRL); 1560 1552 1561 1553 /* for internal loopback we need LOOPS=1 and RSRC=0 */ 1562 - reg &= ~(UARTCTRL_LOOPS | UARTCTRL_RSRC); 1554 + ctrl &= ~(UARTCTRL_LOOPS | UARTCTRL_RSRC); 1563 1555 if (mctrl & TIOCM_LOOP) 1564 - reg |= UARTCTRL_LOOPS; 1556 + ctrl |= UARTCTRL_LOOPS; 1565 1557 1566 - lpuart32_write(port, reg, UARTCTRL); 1558 + lpuart32_write(port, ctrl, UARTCTRL); 1567 1559 } 1568 1560 1569 1561 static void lpuart_break_ctl(struct uart_port *port, int break_state) 1570 1562 { 1571 - unsigned char temp; 1563 + u8 cr2; 1572 1564 1573 - temp = readb(port->membase + UARTCR2) & ~UARTCR2_SBK; 1565 + cr2 = readb(port->membase + UARTCR2) & ~UARTCR2_SBK; 1574 1566 1575 1567 if (break_state != 0) 1576 - temp |= UARTCR2_SBK; 1568 + cr2 |= UARTCR2_SBK; 1577 1569 1578 - writeb(temp, port->membase + UARTCR2); 1570 + writeb(cr2, port->membase + UARTCR2); 1579 1571 } 1580 1572 1581 1573 static void lpuart32_break_ctl(struct uart_port *port, int break_state) 1582 1574 { 1583 - unsigned long temp; 1575 + u32 ctrl; 1584 1576 1585 - temp = lpuart32_read(port, UARTCTRL); 1577 + ctrl = lpuart32_read(port, UARTCTRL); 1586 1578 1587 1579 /* 1588 1580 * LPUART IP now has two known bugs, one is CTS has higher priority than the ··· 1599 1591 * Disable the transmitter to prevent any data from being sent out 1600 1592 * during break, then invert the TX line to send break. 1601 1593 */ 1602 - temp &= ~UARTCTRL_TE; 1603 - lpuart32_write(port, temp, UARTCTRL); 1604 - temp |= UARTCTRL_TXINV; 1605 - lpuart32_write(port, temp, UARTCTRL); 1594 + ctrl &= ~UARTCTRL_TE; 1595 + lpuart32_write(port, ctrl, UARTCTRL); 1596 + ctrl |= UARTCTRL_TXINV; 1597 + lpuart32_write(port, ctrl, UARTCTRL); 1606 1598 } else { 1607 1599 /* Disable the TXINV to turn off break and re-enable transmitter. */ 1608 - temp &= ~UARTCTRL_TXINV; 1609 - lpuart32_write(port, temp, UARTCTRL); 1610 - temp |= UARTCTRL_TE; 1611 - lpuart32_write(port, temp, UARTCTRL); 1600 + ctrl &= ~UARTCTRL_TXINV; 1601 + lpuart32_write(port, ctrl, UARTCTRL); 1602 + ctrl |= UARTCTRL_TE; 1603 + lpuart32_write(port, ctrl, UARTCTRL); 1612 1604 } 1613 1605 } 1614 1606 1615 1607 static void lpuart_setup_watermark(struct lpuart_port *sport) 1616 1608 { 1617 - unsigned char val, cr2; 1618 - unsigned char cr2_saved; 1609 + u8 fifo, cr2, cr2_saved; 1619 1610 1620 1611 cr2 = readb(sport->port.membase + UARTCR2); 1621 1612 cr2_saved = cr2; ··· 1622 1615 UARTCR2_RIE | UARTCR2_RE); 1623 1616 writeb(cr2, sport->port.membase + UARTCR2); 1624 1617 1625 - val = readb(sport->port.membase + UARTPFIFO); 1626 - writeb(val | UARTPFIFO_TXFE | UARTPFIFO_RXFE, 1618 + fifo = readb(sport->port.membase + UARTPFIFO); 1619 + writeb(fifo | UARTPFIFO_TXFE | UARTPFIFO_RXFE, 1627 1620 sport->port.membase + UARTPFIFO); 1628 1621 1629 1622 /* flush Tx and Rx FIFO */ ··· 1647 1640 1648 1641 static void lpuart_setup_watermark_enable(struct lpuart_port *sport) 1649 1642 { 1650 - unsigned char cr2; 1643 + u8 cr2; 1651 1644 1652 1645 lpuart_setup_watermark(sport); 1653 1646 ··· 1658 1651 1659 1652 static void lpuart32_setup_watermark(struct lpuart_port *sport) 1660 1653 { 1661 - unsigned long val, ctrl; 1662 - unsigned long ctrl_saved; 1654 + u32 val, ctrl, ctrl_saved; 1663 1655 1664 1656 ctrl = lpuart32_read(&sport->port, UARTCTRL); 1665 1657 ctrl_saved = ctrl; ··· 1693 1687 1694 1688 static void lpuart32_setup_watermark_enable(struct lpuart_port *sport) 1695 1689 { 1696 - u32 temp; 1690 + u32 ctrl; 1697 1691 1698 1692 lpuart32_setup_watermark(sport); 1699 1693 1700 - temp = lpuart32_read(&sport->port, UARTCTRL); 1701 - temp |= UARTCTRL_RE | UARTCTRL_TE; 1702 - temp |= FIELD_PREP(UARTCTRL_IDLECFG, 0x7); 1703 - lpuart32_write(&sport->port, temp, UARTCTRL); 1694 + ctrl = lpuart32_read(&sport->port, UARTCTRL); 1695 + ctrl |= UARTCTRL_RE | UARTCTRL_TE; 1696 + ctrl |= FIELD_PREP(UARTCTRL_IDLECFG, 0x7); 1697 + lpuart32_write(&sport->port, ctrl, UARTCTRL); 1704 1698 } 1705 1699 1706 1700 static void rx_dma_timer_init(struct lpuart_port *sport) ··· 1767 1761 static void lpuart_rx_dma_startup(struct lpuart_port *sport) 1768 1762 { 1769 1763 int ret; 1770 - unsigned char cr3; 1764 + u8 cr3; 1771 1765 1772 1766 if (uart_console(&sport->port)) 1773 1767 goto err; ··· 1817 1811 static int lpuart_startup(struct uart_port *port) 1818 1812 { 1819 1813 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 1820 - unsigned char temp; 1814 + u8 fifo; 1821 1815 1822 1816 /* determine FIFO size and enable FIFO mode */ 1823 - temp = readb(sport->port.membase + UARTPFIFO); 1817 + fifo = readb(port->membase + UARTPFIFO); 1824 1818 1825 - sport->txfifo_size = UARTFIFO_DEPTH((temp >> UARTPFIFO_TXSIZE_OFF) & 1819 + sport->txfifo_size = UARTFIFO_DEPTH((fifo >> UARTPFIFO_TXSIZE_OFF) & 1826 1820 UARTPFIFO_FIFOSIZE_MASK); 1827 - sport->port.fifosize = sport->txfifo_size; 1821 + port->fifosize = sport->txfifo_size; 1828 1822 1829 - sport->rxfifo_size = UARTFIFO_DEPTH((temp >> UARTPFIFO_RXSIZE_OFF) & 1823 + sport->rxfifo_size = UARTFIFO_DEPTH((fifo >> UARTPFIFO_RXSIZE_OFF) & 1830 1824 UARTPFIFO_FIFOSIZE_MASK); 1831 1825 1832 1826 lpuart_request_dma(sport); ··· 1837 1831 1838 1832 static void lpuart32_hw_disable(struct lpuart_port *sport) 1839 1833 { 1840 - unsigned long temp; 1834 + u32 ctrl; 1841 1835 1842 - temp = lpuart32_read(&sport->port, UARTCTRL); 1843 - temp &= ~(UARTCTRL_RIE | UARTCTRL_ILIE | UARTCTRL_RE | 1836 + ctrl = lpuart32_read(&sport->port, UARTCTRL); 1837 + ctrl &= ~(UARTCTRL_RIE | UARTCTRL_ILIE | UARTCTRL_RE | 1844 1838 UARTCTRL_TIE | UARTCTRL_TE); 1845 - lpuart32_write(&sport->port, temp, UARTCTRL); 1839 + lpuart32_write(&sport->port, ctrl, UARTCTRL); 1846 1840 } 1847 1841 1848 1842 static void lpuart32_configure(struct lpuart_port *sport) 1849 1843 { 1850 - unsigned long temp; 1844 + u32 ctrl; 1851 1845 1852 - temp = lpuart32_read(&sport->port, UARTCTRL); 1846 + ctrl = lpuart32_read(&sport->port, UARTCTRL); 1853 1847 if (!sport->lpuart_dma_rx_use) 1854 - temp |= UARTCTRL_RIE | UARTCTRL_ILIE; 1848 + ctrl |= UARTCTRL_RIE | UARTCTRL_ILIE; 1855 1849 if (!sport->lpuart_dma_tx_use) 1856 - temp |= UARTCTRL_TIE; 1857 - lpuart32_write(&sport->port, temp, UARTCTRL); 1850 + ctrl |= UARTCTRL_TIE; 1851 + lpuart32_write(&sport->port, ctrl, UARTCTRL); 1858 1852 } 1859 1853 1860 1854 static void lpuart32_hw_setup(struct lpuart_port *sport) ··· 1877 1871 static int lpuart32_startup(struct uart_port *port) 1878 1872 { 1879 1873 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 1880 - unsigned long temp; 1874 + u32 fifo; 1881 1875 1882 1876 /* determine FIFO size */ 1883 - temp = lpuart32_read(&sport->port, UARTFIFO); 1877 + fifo = lpuart32_read(port, UARTFIFO); 1884 1878 1885 - sport->txfifo_size = UARTFIFO_DEPTH((temp >> UARTFIFO_TXSIZE_OFF) & 1879 + sport->txfifo_size = UARTFIFO_DEPTH((fifo >> UARTFIFO_TXSIZE_OFF) & 1886 1880 UARTFIFO_FIFOSIZE_MASK); 1887 - sport->port.fifosize = sport->txfifo_size; 1881 + port->fifosize = sport->txfifo_size; 1888 1882 1889 - sport->rxfifo_size = UARTFIFO_DEPTH((temp >> UARTFIFO_RXSIZE_OFF) & 1883 + sport->rxfifo_size = UARTFIFO_DEPTH((fifo >> UARTFIFO_RXSIZE_OFF) & 1890 1884 UARTFIFO_FIFOSIZE_MASK); 1891 1885 1892 1886 /* ··· 1897 1891 if (is_layerscape_lpuart(sport)) { 1898 1892 sport->rxfifo_size = 16; 1899 1893 sport->txfifo_size = 16; 1900 - sport->port.fifosize = sport->txfifo_size; 1894 + port->fifosize = sport->txfifo_size; 1901 1895 } 1902 1896 1903 1897 lpuart_request_dma(sport); ··· 1931 1925 static void lpuart_shutdown(struct uart_port *port) 1932 1926 { 1933 1927 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 1934 - unsigned char temp; 1928 + u8 cr2; 1935 1929 unsigned long flags; 1936 1930 1937 1931 uart_port_lock_irqsave(port, &flags); 1938 1932 1939 1933 /* disable Rx/Tx and interrupts */ 1940 - temp = readb(port->membase + UARTCR2); 1941 - temp &= ~(UARTCR2_TE | UARTCR2_RE | 1934 + cr2 = readb(port->membase + UARTCR2); 1935 + cr2 &= ~(UARTCR2_TE | UARTCR2_RE | 1942 1936 UARTCR2_TIE | UARTCR2_TCIE | UARTCR2_RIE); 1943 - writeb(temp, port->membase + UARTCR2); 1937 + writeb(cr2, port->membase + UARTCR2); 1944 1938 1945 1939 uart_port_unlock_irqrestore(port, flags); 1946 1940 ··· 1951 1945 { 1952 1946 struct lpuart_port *sport = 1953 1947 container_of(port, struct lpuart_port, port); 1954 - unsigned long temp; 1948 + u32 temp; 1955 1949 unsigned long flags; 1956 1950 1957 1951 uart_port_lock_irqsave(port, &flags); 1958 1952 1959 1953 /* clear status */ 1960 - temp = lpuart32_read(&sport->port, UARTSTAT); 1961 - lpuart32_write(&sport->port, temp, UARTSTAT); 1954 + temp = lpuart32_read(port, UARTSTAT); 1955 + lpuart32_write(port, temp, UARTSTAT); 1962 1956 1963 1957 /* disable Rx/Tx DMA */ 1964 1958 temp = lpuart32_read(port, UARTBAUD); ··· 1987 1981 { 1988 1982 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 1989 1983 unsigned long flags; 1990 - unsigned char cr1, old_cr1, old_cr2, cr3, cr4, bdh, modem; 1984 + u8 cr1, old_cr1, old_cr2, cr3, cr4, bdh, modem; 1991 1985 unsigned int baud; 1992 1986 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; 1993 1987 unsigned int sbr, brfa; 1994 1988 1995 - cr1 = old_cr1 = readb(sport->port.membase + UARTCR1); 1996 - old_cr2 = readb(sport->port.membase + UARTCR2); 1997 - cr3 = readb(sport->port.membase + UARTCR3); 1998 - cr4 = readb(sport->port.membase + UARTCR4); 1999 - bdh = readb(sport->port.membase + UARTBDH); 2000 - modem = readb(sport->port.membase + UARTMODEM); 1989 + cr1 = old_cr1 = readb(port->membase + UARTCR1); 1990 + old_cr2 = readb(port->membase + UARTCR2); 1991 + cr3 = readb(port->membase + UARTCR3); 1992 + cr4 = readb(port->membase + UARTCR4); 1993 + bdh = readb(port->membase + UARTBDH); 1994 + modem = readb(port->membase + UARTMODEM); 2001 1995 /* 2002 1996 * only support CS8 and CS7, and for CS7 must enable PE. 2003 1997 * supported mode: ··· 2029 2023 * When auto RS-485 RTS mode is enabled, 2030 2024 * hardware flow control need to be disabled. 2031 2025 */ 2032 - if (sport->port.rs485.flags & SER_RS485_ENABLED) 2026 + if (port->rs485.flags & SER_RS485_ENABLED) 2033 2027 termios->c_cflag &= ~CRTSCTS; 2034 2028 2035 2029 if (termios->c_cflag & CRTSCTS) ··· 2070 2064 * Need to update the Ring buffer length according to the selected 2071 2065 * baud rate and restart Rx DMA path. 2072 2066 * 2073 - * Since timer function acqures sport->port.lock, need to stop before 2067 + * Since timer function acqures port->lock, need to stop before 2074 2068 * acquring same lock because otherwise del_timer_sync() can deadlock. 2075 2069 */ 2076 2070 if (old && sport->lpuart_dma_rx_use) 2077 - lpuart_dma_rx_free(&sport->port); 2071 + lpuart_dma_rx_free(port); 2078 2072 2079 - uart_port_lock_irqsave(&sport->port, &flags); 2073 + uart_port_lock_irqsave(port, &flags); 2080 2074 2081 - sport->port.read_status_mask = 0; 2075 + port->read_status_mask = 0; 2082 2076 if (termios->c_iflag & INPCK) 2083 - sport->port.read_status_mask |= UARTSR1_FE | UARTSR1_PE; 2077 + port->read_status_mask |= UARTSR1_FE | UARTSR1_PE; 2084 2078 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) 2085 - sport->port.read_status_mask |= UARTSR1_FE; 2079 + port->read_status_mask |= UARTSR1_FE; 2086 2080 2087 2081 /* characters to ignore */ 2088 - sport->port.ignore_status_mask = 0; 2082 + port->ignore_status_mask = 0; 2089 2083 if (termios->c_iflag & IGNPAR) 2090 - sport->port.ignore_status_mask |= UARTSR1_PE; 2084 + port->ignore_status_mask |= UARTSR1_PE; 2091 2085 if (termios->c_iflag & IGNBRK) { 2092 - sport->port.ignore_status_mask |= UARTSR1_FE; 2086 + port->ignore_status_mask |= UARTSR1_FE; 2093 2087 /* 2094 2088 * if we're ignoring parity and break indicators, 2095 2089 * ignore overruns too (for real raw support). 2096 2090 */ 2097 2091 if (termios->c_iflag & IGNPAR) 2098 - sport->port.ignore_status_mask |= UARTSR1_OR; 2092 + port->ignore_status_mask |= UARTSR1_OR; 2099 2093 } 2100 2094 2101 2095 /* update the per-port timeout */ 2102 2096 uart_update_timeout(port, termios->c_cflag, baud); 2103 2097 2104 2098 /* wait transmit engin complete */ 2105 - lpuart_wait_bit_set(&sport->port, UARTSR1, UARTSR1_TC); 2099 + lpuart_wait_bit_set(port, UARTSR1, UARTSR1_TC); 2106 2100 2107 2101 /* disable transmit and receive */ 2108 2102 writeb(old_cr2 & ~(UARTCR2_TE | UARTCR2_RE), 2109 - sport->port.membase + UARTCR2); 2103 + port->membase + UARTCR2); 2110 2104 2111 - sbr = sport->port.uartclk / (16 * baud); 2112 - brfa = ((sport->port.uartclk - (16 * sbr * baud)) * 2) / baud; 2105 + sbr = port->uartclk / (16 * baud); 2106 + brfa = ((port->uartclk - (16 * sbr * baud)) * 2) / baud; 2113 2107 bdh &= ~UARTBDH_SBR_MASK; 2114 2108 bdh |= (sbr >> 8) & 0x1F; 2115 2109 cr4 &= ~UARTCR4_BRFA_MASK; 2116 2110 brfa &= UARTCR4_BRFA_MASK; 2117 - writeb(cr4 | brfa, sport->port.membase + UARTCR4); 2118 - writeb(bdh, sport->port.membase + UARTBDH); 2119 - writeb(sbr & 0xFF, sport->port.membase + UARTBDL); 2120 - writeb(cr3, sport->port.membase + UARTCR3); 2121 - writeb(cr1, sport->port.membase + UARTCR1); 2122 - writeb(modem, sport->port.membase + UARTMODEM); 2111 + writeb(cr4 | brfa, port->membase + UARTCR4); 2112 + writeb(bdh, port->membase + UARTBDH); 2113 + writeb(sbr & 0xFF, port->membase + UARTBDL); 2114 + writeb(cr3, port->membase + UARTCR3); 2115 + writeb(cr1, port->membase + UARTCR1); 2116 + writeb(modem, port->membase + UARTMODEM); 2123 2117 2124 2118 /* restore control register */ 2125 - writeb(old_cr2, sport->port.membase + UARTCR2); 2119 + writeb(old_cr2, port->membase + UARTCR2); 2126 2120 2127 2121 if (old && sport->lpuart_dma_rx_use) { 2128 2122 if (!lpuart_start_rx_dma(sport)) ··· 2131 2125 sport->lpuart_dma_rx_use = false; 2132 2126 } 2133 2127 2134 - uart_port_unlock_irqrestore(&sport->port, flags); 2128 + uart_port_unlock_irqrestore(port, flags); 2135 2129 } 2136 2130 2137 2131 static void __lpuart32_serial_setbrg(struct uart_port *port, 2138 2132 unsigned int baudrate, bool use_rx_dma, 2139 2133 bool use_tx_dma) 2140 2134 { 2141 - u32 sbr, osr, baud_diff, tmp_osr, tmp_sbr, tmp_diff, tmp; 2135 + u32 sbr, osr, baud_diff, tmp_osr, tmp_sbr, tmp_diff, baud; 2142 2136 u32 clk = port->uartclk; 2143 2137 2144 2138 /* ··· 2167 2161 tmp_diff = clk / (tmp_osr * tmp_sbr) - baudrate; 2168 2162 2169 2163 /* select best values between sbr and sbr+1 */ 2170 - tmp = clk / (tmp_osr * (tmp_sbr + 1)); 2171 - if (tmp_diff > (baudrate - tmp)) { 2172 - tmp_diff = baudrate - tmp; 2164 + baud = clk / (tmp_osr * (tmp_sbr + 1)); 2165 + if (tmp_diff > (baudrate - baud)) { 2166 + tmp_diff = baudrate - baud; 2173 2167 tmp_sbr++; 2174 2168 } 2175 2169 ··· 2191 2185 dev_warn(port->dev, 2192 2186 "unacceptable baud rate difference of more than 3%%\n"); 2193 2187 2194 - tmp = lpuart32_read(port, UARTBAUD); 2188 + baud = lpuart32_read(port, UARTBAUD); 2195 2189 2196 2190 if ((osr > 3) && (osr < 8)) 2197 - tmp |= UARTBAUD_BOTHEDGE; 2191 + baud |= UARTBAUD_BOTHEDGE; 2198 2192 2199 - tmp &= ~(UARTBAUD_OSR_MASK << UARTBAUD_OSR_SHIFT); 2200 - tmp |= ((osr-1) & UARTBAUD_OSR_MASK) << UARTBAUD_OSR_SHIFT; 2193 + baud &= ~(UARTBAUD_OSR_MASK << UARTBAUD_OSR_SHIFT); 2194 + baud |= ((osr-1) & UARTBAUD_OSR_MASK) << UARTBAUD_OSR_SHIFT; 2201 2195 2202 - tmp &= ~UARTBAUD_SBR_MASK; 2203 - tmp |= sbr & UARTBAUD_SBR_MASK; 2196 + baud &= ~UARTBAUD_SBR_MASK; 2197 + baud |= sbr & UARTBAUD_SBR_MASK; 2204 2198 2205 2199 if (!use_rx_dma) 2206 - tmp &= ~UARTBAUD_RDMAE; 2200 + baud &= ~UARTBAUD_RDMAE; 2207 2201 if (!use_tx_dma) 2208 - tmp &= ~UARTBAUD_TDMAE; 2202 + baud &= ~UARTBAUD_TDMAE; 2209 2203 2210 - lpuart32_write(port, tmp, UARTBAUD); 2204 + lpuart32_write(port, baud, UARTBAUD); 2211 2205 } 2212 2206 2213 2207 static void lpuart32_serial_setbrg(struct lpuart_port *sport, ··· 2225 2219 { 2226 2220 struct lpuart_port *sport = container_of(port, struct lpuart_port, port); 2227 2221 unsigned long flags; 2228 - unsigned long ctrl, old_ctrl, bd, modem; 2222 + u32 ctrl, old_ctrl, bd, modem; 2229 2223 unsigned int baud; 2230 2224 unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8; 2231 2225 2232 - ctrl = old_ctrl = lpuart32_read(&sport->port, UARTCTRL); 2233 - bd = lpuart32_read(&sport->port, UARTBAUD); 2234 - modem = lpuart32_read(&sport->port, UARTMODIR); 2226 + ctrl = old_ctrl = lpuart32_read(port, UARTCTRL); 2227 + bd = lpuart32_read(port, UARTBAUD); 2228 + modem = lpuart32_read(port, UARTMODIR); 2235 2229 sport->is_cs7 = false; 2236 2230 /* 2237 2231 * only support CS8 and CS7 ··· 2265 2259 * When auto RS-485 RTS mode is enabled, 2266 2260 * hardware flow control need to be disabled. 2267 2261 */ 2268 - if (sport->port.rs485.flags & SER_RS485_ENABLED) 2262 + if (port->rs485.flags & SER_RS485_ENABLED) 2269 2263 termios->c_cflag &= ~CRTSCTS; 2270 2264 2271 2265 if (termios->c_cflag & CRTSCTS) ··· 2315 2309 * Need to update the Ring buffer length according to the selected 2316 2310 * baud rate and restart Rx DMA path. 2317 2311 * 2318 - * Since timer function acqures sport->port.lock, need to stop before 2312 + * Since timer function acqures port->lock, need to stop before 2319 2313 * acquring same lock because otherwise del_timer_sync() can deadlock. 2320 2314 */ 2321 2315 if (old && sport->lpuart_dma_rx_use) 2322 - lpuart_dma_rx_free(&sport->port); 2316 + lpuart_dma_rx_free(port); 2323 2317 2324 - uart_port_lock_irqsave(&sport->port, &flags); 2318 + uart_port_lock_irqsave(port, &flags); 2325 2319 2326 - sport->port.read_status_mask = 0; 2320 + port->read_status_mask = 0; 2327 2321 if (termios->c_iflag & INPCK) 2328 - sport->port.read_status_mask |= UARTSTAT_FE | UARTSTAT_PE; 2322 + port->read_status_mask |= UARTSTAT_FE | UARTSTAT_PE; 2329 2323 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) 2330 - sport->port.read_status_mask |= UARTSTAT_FE; 2324 + port->read_status_mask |= UARTSTAT_FE; 2331 2325 2332 2326 /* characters to ignore */ 2333 - sport->port.ignore_status_mask = 0; 2327 + port->ignore_status_mask = 0; 2334 2328 if (termios->c_iflag & IGNPAR) 2335 - sport->port.ignore_status_mask |= UARTSTAT_PE; 2329 + port->ignore_status_mask |= UARTSTAT_PE; 2336 2330 if (termios->c_iflag & IGNBRK) { 2337 - sport->port.ignore_status_mask |= UARTSTAT_FE; 2331 + port->ignore_status_mask |= UARTSTAT_FE; 2338 2332 /* 2339 2333 * if we're ignoring parity and break indicators, 2340 2334 * ignore overruns too (for real raw support). 2341 2335 */ 2342 2336 if (termios->c_iflag & IGNPAR) 2343 - sport->port.ignore_status_mask |= UARTSTAT_OR; 2337 + port->ignore_status_mask |= UARTSTAT_OR; 2344 2338 } 2345 2339 2346 2340 /* update the per-port timeout */ 2347 2341 uart_update_timeout(port, termios->c_cflag, baud); 2348 2342 2349 2343 /* 2344 + * disable CTS to ensure the transmit engine is not blocked by the flow 2345 + * control when there is dirty data in TX FIFO 2346 + */ 2347 + lpuart32_write(port, modem & ~UARTMODIR_TXCTSE, UARTMODIR); 2348 + 2349 + /* 2350 2350 * LPUART Transmission Complete Flag may never be set while queuing a break 2351 2351 * character, so skip waiting for transmission complete when UARTCTRL_SBK is 2352 2352 * asserted. 2353 2353 */ 2354 - if (!(old_ctrl & UARTCTRL_SBK)) { 2355 - lpuart32_write(&sport->port, 0, UARTMODIR); 2356 - lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC); 2357 - } 2354 + if (!(old_ctrl & UARTCTRL_SBK)) 2355 + lpuart32_wait_bit_set(port, UARTSTAT, UARTSTAT_TC); 2358 2356 2359 2357 /* disable transmit and receive */ 2360 - lpuart32_write(&sport->port, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE), 2358 + lpuart32_write(port, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE), 2361 2359 UARTCTRL); 2362 2360 2363 - lpuart32_write(&sport->port, bd, UARTBAUD); 2361 + lpuart32_write(port, bd, UARTBAUD); 2364 2362 lpuart32_serial_setbrg(sport, baud); 2365 - /* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */ 2366 - lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, UARTMODIR); 2367 2363 /* restore control register */ 2368 - lpuart32_write(&sport->port, ctrl, UARTCTRL); 2364 + lpuart32_write(port, ctrl, UARTCTRL); 2369 2365 /* re-enable the CTS if needed */ 2370 - lpuart32_write(&sport->port, modem, UARTMODIR); 2366 + lpuart32_write(port, modem, UARTMODIR); 2371 2367 2372 2368 if ((ctrl & (UARTCTRL_PE | UARTCTRL_M)) == UARTCTRL_PE) 2373 2369 sport->is_cs7 = true; ··· 2381 2373 sport->lpuart_dma_rx_use = false; 2382 2374 } 2383 2375 2384 - uart_port_unlock_irqrestore(&sport->port, flags); 2376 + uart_port_unlock_irqrestore(port, flags); 2385 2377 } 2386 2378 2387 2379 static const char *lpuart_type(struct uart_port *port) ··· 2494 2486 lpuart_console_write(struct console *co, const char *s, unsigned int count) 2495 2487 { 2496 2488 struct lpuart_port *sport = lpuart_ports[co->index]; 2497 - unsigned char old_cr2, cr2; 2489 + u8 old_cr2, cr2; 2498 2490 unsigned long flags; 2499 2491 int locked = 1; 2500 2492 ··· 2524 2516 lpuart32_console_write(struct console *co, const char *s, unsigned int count) 2525 2517 { 2526 2518 struct lpuart_port *sport = lpuart_ports[co->index]; 2527 - unsigned long old_cr, cr; 2519 + u32 old_cr, cr; 2528 2520 unsigned long flags; 2529 2521 int locked = 1; 2530 2522 ··· 2558 2550 lpuart_console_get_options(struct lpuart_port *sport, int *baud, 2559 2551 int *parity, int *bits) 2560 2552 { 2561 - unsigned char cr, bdh, bdl, brfa; 2553 + u8 cr, bdh, bdl, brfa; 2562 2554 unsigned int sbr, uartclk, baud_raw; 2563 2555 2564 2556 cr = readb(sport->port.membase + UARTCR2); ··· 2607 2599 lpuart32_console_get_options(struct lpuart_port *sport, int *baud, 2608 2600 int *parity, int *bits) 2609 2601 { 2610 - unsigned long cr, bd; 2602 + u32 cr, bd; 2611 2603 unsigned int sbr, uartclk, baud_raw; 2612 2604 2613 2605 cr = lpuart32_read(&sport->port, UARTCTRL); ··· 2813 2805 { 2814 2806 struct uart_port *port = &sport->port; 2815 2807 void __iomem *global_addr; 2816 - unsigned long ctrl, bd; 2808 + u32 ctrl, bd; 2817 2809 unsigned int val = 0; 2818 2810 int ret; 2819 2811 2820 2812 ret = clk_prepare_enable(sport->ipg_clk); 2821 2813 if (ret) { 2822 - dev_err(sport->port.dev, "failed to enable uart ipg clk: %d\n", ret); 2814 + dev_err(port->dev, "failed to enable uart ipg clk: %d\n", ret); 2823 2815 return ret; 2824 2816 } 2825 2817 ··· 2830 2822 */ 2831 2823 ctrl = lpuart32_read(port, UARTCTRL); 2832 2824 if (ctrl & UARTCTRL_TE) { 2833 - bd = lpuart32_read(&sport->port, UARTBAUD); 2825 + bd = lpuart32_read(port, UARTBAUD); 2834 2826 if (read_poll_timeout(lpuart32_tx_empty, val, val, 1, 100000, false, 2835 2827 port)) { 2836 - dev_warn(sport->port.dev, 2828 + dev_warn(port->dev, 2837 2829 "timeout waiting for transmit engine to complete\n"); 2838 2830 clk_disable_unprepare(sport->ipg_clk); 2839 2831 return 0; ··· 2962 2954 goto failed_attach_port; 2963 2955 2964 2956 ret = devm_request_irq(&pdev->dev, sport->port.irq, handler, 0, 2965 - DRIVER_NAME, sport); 2957 + dev_name(&pdev->dev), sport); 2966 2958 if (ret) 2967 2959 goto failed_irq_request; 2968 2960 ··· 3019 3011 3020 3012 static void serial_lpuart_enable_wakeup(struct lpuart_port *sport, bool on) 3021 3013 { 3022 - unsigned int val, baud; 3014 + u32 val, baud; 3023 3015 3024 3016 if (lpuart_is_32(sport)) { 3025 3017 val = lpuart32_read(&sport->port, UARTCTRL); ··· 3084 3076 static int lpuart_resume_noirq(struct device *dev) 3085 3077 { 3086 3078 struct lpuart_port *sport = dev_get_drvdata(dev); 3087 - unsigned int val; 3079 + u32 stat; 3088 3080 3089 3081 pinctrl_pm_select_default_state(dev); 3090 3082 ··· 3093 3085 3094 3086 /* clear the wakeup flags */ 3095 3087 if (lpuart_is_32(sport)) { 3096 - val = lpuart32_read(&sport->port, UARTSTAT); 3097 - lpuart32_write(&sport->port, val, UARTSTAT); 3088 + stat = lpuart32_read(&sport->port, UARTSTAT); 3089 + lpuart32_write(&sport->port, stat, UARTSTAT); 3098 3090 } 3099 3091 } 3100 3092 ··· 3104 3096 static int lpuart_suspend(struct device *dev) 3105 3097 { 3106 3098 struct lpuart_port *sport = dev_get_drvdata(dev); 3107 - unsigned long temp, flags; 3099 + u32 temp; 3100 + unsigned long flags; 3108 3101 3109 3102 uart_suspend_port(&lpuart_reg, &sport->port); 3110 3103 ··· 3185 3176 * in VLLS mode, or restore console setting here. 3186 3177 */ 3187 3178 if (is_imx7ulp_lpuart(sport) && lpuart_uport_is_active(sport) && 3188 - console_suspend_enabled && uart_console(&sport->port)) { 3179 + console_suspend_enabled && uart_console(uport)) { 3189 3180 3190 3181 mutex_lock(&port->mutex); 3191 3182 memset(&termios, 0, sizeof(struct ktermios));
+4 -5
drivers/tty/serial/icom.c
··· 1764 1764 goto probe_exit1; 1765 1765 } 1766 1766 1767 - /* save off irq and request irq line */ 1768 - retval = request_irq(dev->irq, icom_interrupt, IRQF_SHARED, ICOM_DRIVER_NAME, (void *)icom_adapter); 1769 - if (retval) { 1770 - goto probe_exit2; 1771 - } 1767 + /* save off irq and request irq line */ 1768 + retval = request_irq(dev->irq, icom_interrupt, IRQF_SHARED, ICOM_DRIVER_NAME, icom_adapter); 1769 + if (retval) 1770 + goto probe_exit2; 1772 1771 1773 1772 retval = icom_load_ports(icom_adapter); 1774 1773
+1 -1
drivers/tty/serial/imx.c
··· 1608 1608 imx_uart_dma_exit(sport); 1609 1609 } 1610 1610 1611 - mctrl_gpio_disable_ms(sport->gpios); 1611 + mctrl_gpio_disable_ms_sync(sport->gpios); 1612 1612 1613 1613 uart_port_lock_irqsave(&sport->port, &flags); 1614 1614 ucr2 = imx_uart_readl(sport, UCR2);
-280
drivers/tty/serial/kgdb_nmi.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * KGDB NMI serial console 4 - * 5 - * Copyright 2010 Google, Inc. 6 - * Arve Hjønnevåg <arve@android.com> 7 - * Colin Cross <ccross@android.com> 8 - * Copyright 2012 Linaro Ltd. 9 - * Anton Vorontsov <anton.vorontsov@linaro.org> 10 - */ 11 - 12 - #include <linux/kernel.h> 13 - #include <linux/module.h> 14 - #include <linux/compiler.h> 15 - #include <linux/slab.h> 16 - #include <linux/errno.h> 17 - #include <linux/atomic.h> 18 - #include <linux/console.h> 19 - #include <linux/tty.h> 20 - #include <linux/tty_driver.h> 21 - #include <linux/tty_flip.h> 22 - #include <linux/serial_core.h> 23 - #include <linux/interrupt.h> 24 - #include <linux/hrtimer.h> 25 - #include <linux/tick.h> 26 - #include <linux/kfifo.h> 27 - #include <linux/kgdb.h> 28 - #include <linux/kdb.h> 29 - 30 - static atomic_t kgdb_nmi_num_readers = ATOMIC_INIT(0); 31 - 32 - static int kgdb_nmi_console_setup(struct console *co, char *options) 33 - { 34 - arch_kgdb_ops.enable_nmi(1); 35 - 36 - /* The NMI console uses the dbg_io_ops to issue console messages. To 37 - * avoid duplicate messages during kdb sessions we must inform kdb's 38 - * I/O utilities that messages sent to the console will automatically 39 - * be displayed on the dbg_io. 40 - */ 41 - dbg_io_ops->cons = co; 42 - 43 - return 0; 44 - } 45 - 46 - static void kgdb_nmi_console_write(struct console *co, const char *s, uint c) 47 - { 48 - int i; 49 - 50 - for (i = 0; i < c; i++) 51 - dbg_io_ops->write_char(s[i]); 52 - } 53 - 54 - static struct tty_driver *kgdb_nmi_tty_driver; 55 - 56 - static struct tty_driver *kgdb_nmi_console_device(struct console *co, int *idx) 57 - { 58 - *idx = co->index; 59 - return kgdb_nmi_tty_driver; 60 - } 61 - 62 - static struct console kgdb_nmi_console = { 63 - .name = "ttyNMI", 64 - .setup = kgdb_nmi_console_setup, 65 - .write = kgdb_nmi_console_write, 66 - .device = kgdb_nmi_console_device, 67 - .flags = CON_PRINTBUFFER | CON_ANYTIME, 68 - .index = -1, 69 - }; 70 - 71 - /* 72 - * This is usually the maximum rate on debug ports. We make fifo large enough 73 - * to make copy-pasting to the terminal usable. 74 - */ 75 - #define KGDB_NMI_BAUD 115200 76 - #define KGDB_NMI_FIFO_SIZE roundup_pow_of_two(KGDB_NMI_BAUD / 8 / HZ) 77 - 78 - struct kgdb_nmi_tty_priv { 79 - struct tty_port port; 80 - struct timer_list timer; 81 - STRUCT_KFIFO(char, KGDB_NMI_FIFO_SIZE) fifo; 82 - }; 83 - 84 - static struct tty_port *kgdb_nmi_port; 85 - 86 - /* 87 - * The tasklet is cheap, it does not cause wakeups when reschedules itself, 88 - * instead it waits for the next tick. 89 - */ 90 - static void kgdb_nmi_tty_receiver(struct timer_list *t) 91 - { 92 - struct kgdb_nmi_tty_priv *priv = from_timer(priv, t, timer); 93 - char ch; 94 - 95 - priv->timer.expires = jiffies + (HZ/100); 96 - add_timer(&priv->timer); 97 - 98 - if (likely(!atomic_read(&kgdb_nmi_num_readers) || 99 - !kfifo_len(&priv->fifo))) 100 - return; 101 - 102 - while (kfifo_out(&priv->fifo, &ch, 1)) 103 - tty_insert_flip_char(&priv->port, ch, TTY_NORMAL); 104 - tty_flip_buffer_push(&priv->port); 105 - } 106 - 107 - static int kgdb_nmi_tty_activate(struct tty_port *port, struct tty_struct *tty) 108 - { 109 - struct kgdb_nmi_tty_priv *priv = 110 - container_of(port, struct kgdb_nmi_tty_priv, port); 111 - 112 - kgdb_nmi_port = port; 113 - priv->timer.expires = jiffies + (HZ/100); 114 - add_timer(&priv->timer); 115 - 116 - return 0; 117 - } 118 - 119 - static void kgdb_nmi_tty_shutdown(struct tty_port *port) 120 - { 121 - struct kgdb_nmi_tty_priv *priv = 122 - container_of(port, struct kgdb_nmi_tty_priv, port); 123 - 124 - del_timer(&priv->timer); 125 - kgdb_nmi_port = NULL; 126 - } 127 - 128 - static const struct tty_port_operations kgdb_nmi_tty_port_ops = { 129 - .activate = kgdb_nmi_tty_activate, 130 - .shutdown = kgdb_nmi_tty_shutdown, 131 - }; 132 - 133 - static int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty) 134 - { 135 - struct kgdb_nmi_tty_priv *priv; 136 - int ret; 137 - 138 - priv = kzalloc(sizeof(*priv), GFP_KERNEL); 139 - if (!priv) 140 - return -ENOMEM; 141 - 142 - INIT_KFIFO(priv->fifo); 143 - timer_setup(&priv->timer, kgdb_nmi_tty_receiver, 0); 144 - tty_port_init(&priv->port); 145 - priv->port.ops = &kgdb_nmi_tty_port_ops; 146 - tty->driver_data = priv; 147 - 148 - ret = tty_port_install(&priv->port, drv, tty); 149 - if (ret) { 150 - pr_err("%s: can't install tty port: %d\n", __func__, ret); 151 - goto err; 152 - } 153 - return 0; 154 - err: 155 - tty_port_destroy(&priv->port); 156 - kfree(priv); 157 - return ret; 158 - } 159 - 160 - static void kgdb_nmi_tty_cleanup(struct tty_struct *tty) 161 - { 162 - struct kgdb_nmi_tty_priv *priv = tty->driver_data; 163 - 164 - tty->driver_data = NULL; 165 - tty_port_destroy(&priv->port); 166 - kfree(priv); 167 - } 168 - 169 - static int kgdb_nmi_tty_open(struct tty_struct *tty, struct file *file) 170 - { 171 - struct kgdb_nmi_tty_priv *priv = tty->driver_data; 172 - unsigned int mode = file->f_flags & O_ACCMODE; 173 - int ret; 174 - 175 - ret = tty_port_open(&priv->port, tty, file); 176 - if (!ret && (mode == O_RDONLY || mode == O_RDWR)) 177 - atomic_inc(&kgdb_nmi_num_readers); 178 - 179 - return ret; 180 - } 181 - 182 - static void kgdb_nmi_tty_close(struct tty_struct *tty, struct file *file) 183 - { 184 - struct kgdb_nmi_tty_priv *priv = tty->driver_data; 185 - unsigned int mode = file->f_flags & O_ACCMODE; 186 - 187 - if (mode == O_RDONLY || mode == O_RDWR) 188 - atomic_dec(&kgdb_nmi_num_readers); 189 - 190 - tty_port_close(&priv->port, tty, file); 191 - } 192 - 193 - static void kgdb_nmi_tty_hangup(struct tty_struct *tty) 194 - { 195 - struct kgdb_nmi_tty_priv *priv = tty->driver_data; 196 - 197 - tty_port_hangup(&priv->port); 198 - } 199 - 200 - static unsigned int kgdb_nmi_tty_write_room(struct tty_struct *tty) 201 - { 202 - /* Actually, we can handle any amount as we use polled writes. */ 203 - return 2048; 204 - } 205 - 206 - static ssize_t kgdb_nmi_tty_write(struct tty_struct *tty, const u8 *buf, 207 - size_t c) 208 - { 209 - int i; 210 - 211 - for (i = 0; i < c; i++) 212 - dbg_io_ops->write_char(buf[i]); 213 - return c; 214 - } 215 - 216 - static const struct tty_operations kgdb_nmi_tty_ops = { 217 - .open = kgdb_nmi_tty_open, 218 - .close = kgdb_nmi_tty_close, 219 - .install = kgdb_nmi_tty_install, 220 - .cleanup = kgdb_nmi_tty_cleanup, 221 - .hangup = kgdb_nmi_tty_hangup, 222 - .write_room = kgdb_nmi_tty_write_room, 223 - .write = kgdb_nmi_tty_write, 224 - }; 225 - 226 - int kgdb_register_nmi_console(void) 227 - { 228 - int ret; 229 - 230 - if (!arch_kgdb_ops.enable_nmi) 231 - return 0; 232 - 233 - kgdb_nmi_tty_driver = tty_alloc_driver(1, TTY_DRIVER_REAL_RAW); 234 - if (IS_ERR(kgdb_nmi_tty_driver)) { 235 - pr_err("%s: cannot allocate tty\n", __func__); 236 - return PTR_ERR(kgdb_nmi_tty_driver); 237 - } 238 - kgdb_nmi_tty_driver->driver_name = "ttyNMI"; 239 - kgdb_nmi_tty_driver->name = "ttyNMI"; 240 - kgdb_nmi_tty_driver->num = 1; 241 - kgdb_nmi_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 242 - kgdb_nmi_tty_driver->subtype = SERIAL_TYPE_NORMAL; 243 - kgdb_nmi_tty_driver->init_termios = tty_std_termios; 244 - tty_termios_encode_baud_rate(&kgdb_nmi_tty_driver->init_termios, 245 - KGDB_NMI_BAUD, KGDB_NMI_BAUD); 246 - tty_set_operations(kgdb_nmi_tty_driver, &kgdb_nmi_tty_ops); 247 - 248 - ret = tty_register_driver(kgdb_nmi_tty_driver); 249 - if (ret) { 250 - pr_err("%s: can't register tty driver: %d\n", __func__, ret); 251 - goto err_drv_reg; 252 - } 253 - 254 - register_console(&kgdb_nmi_console); 255 - 256 - return 0; 257 - err_drv_reg: 258 - tty_driver_kref_put(kgdb_nmi_tty_driver); 259 - return ret; 260 - } 261 - EXPORT_SYMBOL_GPL(kgdb_register_nmi_console); 262 - 263 - int kgdb_unregister_nmi_console(void) 264 - { 265 - int ret; 266 - 267 - if (!arch_kgdb_ops.enable_nmi) 268 - return 0; 269 - arch_kgdb_ops.enable_nmi(0); 270 - 271 - ret = unregister_console(&kgdb_nmi_console); 272 - if (ret) 273 - return ret; 274 - 275 - tty_unregister_driver(kgdb_nmi_tty_driver); 276 - tty_driver_kref_put(kgdb_nmi_tty_driver); 277 - 278 - return 0; 279 - } 280 - EXPORT_SYMBOL_GPL(kgdb_unregister_nmi_console);
-8
drivers/tty/serial/kgdboc.c
··· 186 186 if (configured != 1) 187 187 return; 188 188 189 - if (kgdb_unregister_nmi_console()) 190 - return; 191 189 kgdboc_unregister_kbd(); 192 190 kgdb_unregister_io_module(&kgdboc_io_ops); 193 191 } ··· 248 250 if (err) 249 251 goto noconfig; 250 252 251 - err = kgdb_register_nmi_console(); 252 - if (err) 253 - goto nmi_con_failed; 254 - 255 253 configured = 1; 256 254 257 255 return 0; 258 256 259 - nmi_con_failed: 260 - kgdb_unregister_io_module(&kgdboc_io_ops); 261 257 noconfig: 262 258 kgdboc_unregister_kbd(); 263 259 configured = 0;
+1 -1
drivers/tty/serial/ma35d1_serial.c
··· 799 799 .resume = ma35d1serial_resume, 800 800 .driver = { 801 801 .name = "ma35d1-uart", 802 - .of_match_table = of_match_ptr(ma35d1_serial_of_match), 802 + .of_match_table = ma35d1_serial_of_match, 803 803 }, 804 804 }; 805 805
-1
drivers/tty/serial/mpc52xx_uart.c
··· 1351 1351 .startup = mpc52xx_uart_startup, 1352 1352 .shutdown = mpc52xx_uart_shutdown, 1353 1353 .set_termios = mpc52xx_uart_set_termios, 1354 - /* .pm = mpc52xx_uart_pm, Not supported yet */ 1355 1354 .type = mpc52xx_uart_type, 1356 1355 .release_port = mpc52xx_uart_release_port, 1357 1356 .request_port = mpc52xx_uart_request_port,
-1
drivers/tty/serial/pch_uart.c
··· 1515 1515 .startup = pch_uart_startup, 1516 1516 .shutdown = pch_uart_shutdown, 1517 1517 .set_termios = pch_uart_set_termios, 1518 - /* .pm = pch_uart_pm, Not supported yet */ 1519 1518 .type = pch_uart_type, 1520 1519 .release_port = pch_uart_release_port, 1521 1520 .request_port = pch_uart_request_port,
+4 -6
drivers/tty/serial/serial_core.c
··· 895 895 { 896 896 struct uart_port *uport = uart_port_check(state); 897 897 unsigned long new_port; 898 - unsigned int change_irq, change_port, closing_wait; 899 - unsigned int old_custom_divisor, close_delay; 898 + unsigned int old_custom_divisor, close_delay, closing_wait; 899 + bool change_irq, change_port; 900 900 upf_t old_flags, new_flags; 901 901 int retval; 902 902 ··· 2013 2013 2014 2014 #ifdef CONFIG_PROC_FS 2015 2015 2016 - static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i) 2016 + static void uart_line_info(struct seq_file *m, struct uart_state *state) 2017 2017 { 2018 - struct uart_state *state = drv->state + i; 2019 2018 struct tty_port *port = &state->port; 2020 2019 enum uart_pm_state pm_state; 2021 2020 struct uart_port *uport; ··· 2099 2100 2100 2101 seq_printf(m, "serinfo:1.0 driver%s%s revision:%s\n", "", "", ""); 2101 2102 for (i = 0; i < drv->nr; i++) 2102 - uart_line_info(m, drv, i); 2103 + uart_line_info(m, drv->state + i); 2103 2104 return 0; 2104 2105 } 2105 2106 #endif ··· 3155 3156 if (uport->cons && uport->dev) 3156 3157 of_console_check(uport->dev->of_node, uport->cons->name, uport->line); 3157 3158 3158 - tty_port_link_device(port, drv->tty_driver, uport->line); 3159 3159 uart_configure_port(drv, state, uport); 3160 3160 3161 3161 port->console = uart_console(uport);
+28 -34
drivers/tty/serial/serial_mctrl_gpio.c
··· 217 217 * 218 218 * This will get the {cts,rts,...}-gpios from device tree if they are present 219 219 * and request them, set direction etc, and return an allocated structure. 220 - * `devm_*` functions are used, so there's no need to call mctrl_gpio_free(). 220 + * `devm_*` functions are used, so there's no need to explicitly free. 221 221 * As this sets up the irq handling, make sure to not handle changes to the 222 222 * gpio input lines in your driver, too. 223 223 */ ··· 268 268 EXPORT_SYMBOL_GPL(mctrl_gpio_init); 269 269 270 270 /** 271 - * mctrl_gpio_free - explicitly free uart gpios 272 - * @dev: uart port's device 273 - * @gpios: gpios structure to be freed 274 - * 275 - * This will free the requested gpios in mctrl_gpio_init(). As `devm_*` 276 - * functions are used, there's generally no need to call this function. 277 - */ 278 - void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios) 279 - { 280 - enum mctrl_gpio_idx i; 281 - 282 - if (gpios == NULL) 283 - return; 284 - 285 - for (i = 0; i < UART_GPIO_MAX; i++) { 286 - if (gpios->irq[i]) 287 - devm_free_irq(gpios->port->dev, gpios->irq[i], gpios); 288 - 289 - if (gpios->gpio[i]) 290 - devm_gpiod_put(dev, gpios->gpio[i]); 291 - } 292 - devm_kfree(dev, gpios); 293 - } 294 - EXPORT_SYMBOL_GPL(mctrl_gpio_free); 295 - 296 - /** 297 271 * mctrl_gpio_enable_ms - enable irqs and handling of changes to the ms lines 298 272 * @gpios: gpios to enable 299 273 */ ··· 296 322 } 297 323 EXPORT_SYMBOL_GPL(mctrl_gpio_enable_ms); 298 324 299 - /** 300 - * mctrl_gpio_disable_ms - disable irqs and handling of changes to the ms lines 301 - * @gpios: gpios to disable 302 - */ 303 - void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios) 325 + static void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios, bool sync) 304 326 { 305 327 enum mctrl_gpio_idx i; 306 328 ··· 312 342 if (!gpios->irq[i]) 313 343 continue; 314 344 315 - disable_irq(gpios->irq[i]); 345 + if (sync) 346 + disable_irq(gpios->irq[i]); 347 + else 348 + disable_irq_nosync(gpios->irq[i]); 316 349 } 317 350 } 318 - EXPORT_SYMBOL_GPL(mctrl_gpio_disable_ms); 351 + 352 + /** 353 + * mctrl_gpio_disable_ms_sync - disable irqs and handling of changes to the ms 354 + * lines, and wait for any pending IRQ to be processed 355 + * @gpios: gpios to disable 356 + */ 357 + void mctrl_gpio_disable_ms_sync(struct mctrl_gpios *gpios) 358 + { 359 + mctrl_gpio_disable_ms(gpios, true); 360 + } 361 + EXPORT_SYMBOL_GPL(mctrl_gpio_disable_ms_sync); 362 + 363 + /** 364 + * mctrl_gpio_disable_ms_no_sync - disable irqs and handling of changes to the 365 + * ms lines, and return immediately 366 + * @gpios: gpios to disable 367 + */ 368 + void mctrl_gpio_disable_ms_no_sync(struct mctrl_gpios *gpios) 369 + { 370 + mctrl_gpio_disable_ms(gpios, false); 371 + } 372 + EXPORT_SYMBOL_GPL(mctrl_gpio_disable_ms_no_sync); 319 373 320 374 void mctrl_gpio_enable_irq_wake(struct mctrl_gpios *gpios) 321 375 {
+16 -17
drivers/tty/serial/serial_mctrl_gpio.h
··· 59 59 /* 60 60 * Request and set direction of modem control line GPIOs and set up irq 61 61 * handling. 62 - * devm_* functions are used, so there's no need to call mctrl_gpio_free(). 62 + * devm_* functions are used, so there's no need to explicitly free. 63 63 * Returns a pointer to the allocated mctrl structure if ok, -ENOMEM on 64 64 * allocation error. 65 65 */ ··· 67 67 68 68 /* 69 69 * Request and set direction of modem control line GPIOs. 70 - * devm_* functions are used, so there's no need to call mctrl_gpio_free(). 70 + * devm_* functions are used, so there's no need to explicitly free. 71 71 * Returns a pointer to the allocated mctrl structure if ok, -ENOMEM on 72 72 * allocation error. 73 73 */ ··· 75 75 unsigned int idx); 76 76 77 77 /* 78 - * Free the mctrl_gpios structure. 79 - * Normally, this function will not be called, as the GPIOs will 80 - * be disposed of by the resource management code. 81 - */ 82 - void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios); 83 - 84 - /* 85 78 * Enable gpio interrupts to report status line changes. 86 79 */ 87 80 void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios); 88 81 89 82 /* 90 - * Disable gpio interrupts to report status line changes. 83 + * Disable gpio interrupts to report status line changes, and block until 84 + * any corresponding IRQ is processed 91 85 */ 92 - void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios); 86 + void mctrl_gpio_disable_ms_sync(struct mctrl_gpios *gpios); 87 + 88 + /* 89 + * Disable gpio interrupts to report status line changes, and return 90 + * immediately 91 + */ 92 + void mctrl_gpio_disable_ms_no_sync(struct mctrl_gpios *gpios); 93 93 94 94 /* 95 95 * Enable gpio wakeup interrupts to enable wake up source. ··· 139 139 return NULL; 140 140 } 141 141 142 - static inline 143 - void mctrl_gpio_free(struct device *dev, struct mctrl_gpios *gpios) 144 - { 145 - } 146 - 147 142 static inline void mctrl_gpio_enable_ms(struct mctrl_gpios *gpios) 148 143 { 149 144 } 150 145 151 - static inline void mctrl_gpio_disable_ms(struct mctrl_gpios *gpios) 146 + static inline void mctrl_gpio_disable_ms_sync(struct mctrl_gpios *gpios) 147 + { 148 + } 149 + 150 + static inline void mctrl_gpio_disable_ms_no_sync(struct mctrl_gpios *gpios) 152 151 { 153 152 } 154 153
+95 -3
drivers/tty/serial/sh-sci.c
··· 104 104 u8 offset, size; 105 105 }; 106 106 107 + struct sci_suspend_regs { 108 + u16 scdl; 109 + u16 sccks; 110 + u16 scsmr; 111 + u16 scscr; 112 + u16 scfcr; 113 + u16 scsptr; 114 + u16 hssrr; 115 + u16 scpcr; 116 + u16 scpdr; 117 + u8 scbrr; 118 + u8 semr; 119 + }; 120 + 107 121 struct sci_port_params { 108 122 const struct plat_sci_reg regs[SCIx_NR_REGS]; 109 123 unsigned int fifosize; ··· 148 134 struct dma_chan *chan_tx; 149 135 struct dma_chan *chan_rx; 150 136 137 + struct reset_control *rstc; 138 + 151 139 #ifdef CONFIG_SERIAL_SH_SCI_DMA 152 140 struct dma_chan *chan_tx_saved; 153 141 struct dma_chan *chan_rx_saved; ··· 169 153 int rx_trigger; 170 154 struct timer_list rx_fifo_timer; 171 155 int rx_fifo_timeout; 156 + struct sci_suspend_regs suspend_regs; 172 157 u16 hscif_tot; 173 158 174 159 bool has_rtscts; ··· 2314 2297 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); 2315 2298 2316 2299 s->autorts = false; 2317 - mctrl_gpio_disable_ms(to_sci_port(port)->gpios); 2300 + mctrl_gpio_disable_ms_sync(to_sci_port(port)->gpios); 2318 2301 2319 2302 uart_port_lock_irqsave(port, &flags); 2320 2303 sci_stop_rx(port); ··· 3390 3373 } 3391 3374 3392 3375 sp = &sci_ports[id]; 3376 + sp->rstc = rstc; 3393 3377 *dev_id = id; 3394 3378 3395 3379 p->type = SCI_OF_TYPE(data); ··· 3563 3545 return 0; 3564 3546 } 3565 3547 3548 + static void sci_console_save(struct sci_port *s) 3549 + { 3550 + struct sci_suspend_regs *regs = &s->suspend_regs; 3551 + struct uart_port *port = &s->port; 3552 + 3553 + if (sci_getreg(port, SCDL)->size) 3554 + regs->scdl = sci_serial_in(port, SCDL); 3555 + if (sci_getreg(port, SCCKS)->size) 3556 + regs->sccks = sci_serial_in(port, SCCKS); 3557 + if (sci_getreg(port, SCSMR)->size) 3558 + regs->scsmr = sci_serial_in(port, SCSMR); 3559 + if (sci_getreg(port, SCSCR)->size) 3560 + regs->scscr = sci_serial_in(port, SCSCR); 3561 + if (sci_getreg(port, SCFCR)->size) 3562 + regs->scfcr = sci_serial_in(port, SCFCR); 3563 + if (sci_getreg(port, SCSPTR)->size) 3564 + regs->scsptr = sci_serial_in(port, SCSPTR); 3565 + if (sci_getreg(port, SCBRR)->size) 3566 + regs->scbrr = sci_serial_in(port, SCBRR); 3567 + if (sci_getreg(port, HSSRR)->size) 3568 + regs->hssrr = sci_serial_in(port, HSSRR); 3569 + if (sci_getreg(port, SCPCR)->size) 3570 + regs->scpcr = sci_serial_in(port, SCPCR); 3571 + if (sci_getreg(port, SCPDR)->size) 3572 + regs->scpdr = sci_serial_in(port, SCPDR); 3573 + if (sci_getreg(port, SEMR)->size) 3574 + regs->semr = sci_serial_in(port, SEMR); 3575 + } 3576 + 3577 + static void sci_console_restore(struct sci_port *s) 3578 + { 3579 + struct sci_suspend_regs *regs = &s->suspend_regs; 3580 + struct uart_port *port = &s->port; 3581 + 3582 + if (sci_getreg(port, SCDL)->size) 3583 + sci_serial_out(port, SCDL, regs->scdl); 3584 + if (sci_getreg(port, SCCKS)->size) 3585 + sci_serial_out(port, SCCKS, regs->sccks); 3586 + if (sci_getreg(port, SCSMR)->size) 3587 + sci_serial_out(port, SCSMR, regs->scsmr); 3588 + if (sci_getreg(port, SCSCR)->size) 3589 + sci_serial_out(port, SCSCR, regs->scscr); 3590 + if (sci_getreg(port, SCFCR)->size) 3591 + sci_serial_out(port, SCFCR, regs->scfcr); 3592 + if (sci_getreg(port, SCSPTR)->size) 3593 + sci_serial_out(port, SCSPTR, regs->scsptr); 3594 + if (sci_getreg(port, SCBRR)->size) 3595 + sci_serial_out(port, SCBRR, regs->scbrr); 3596 + if (sci_getreg(port, HSSRR)->size) 3597 + sci_serial_out(port, HSSRR, regs->hssrr); 3598 + if (sci_getreg(port, SCPCR)->size) 3599 + sci_serial_out(port, SCPCR, regs->scpcr); 3600 + if (sci_getreg(port, SCPDR)->size) 3601 + sci_serial_out(port, SCPDR, regs->scpdr); 3602 + if (sci_getreg(port, SEMR)->size) 3603 + sci_serial_out(port, SEMR, regs->semr); 3604 + } 3605 + 3566 3606 static __maybe_unused int sci_suspend(struct device *dev) 3567 3607 { 3568 3608 struct sci_port *sport = dev_get_drvdata(dev); 3569 3609 3570 - if (sport) 3610 + if (sport) { 3571 3611 uart_suspend_port(&sci_uart_driver, &sport->port); 3612 + 3613 + if (!console_suspend_enabled && uart_console(&sport->port)) 3614 + sci_console_save(sport); 3615 + else 3616 + return reset_control_assert(sport->rstc); 3617 + } 3572 3618 3573 3619 return 0; 3574 3620 } ··· 3641 3559 { 3642 3560 struct sci_port *sport = dev_get_drvdata(dev); 3643 3561 3644 - if (sport) 3562 + if (sport) { 3563 + if (!console_suspend_enabled && uart_console(&sport->port)) { 3564 + sci_console_restore(sport); 3565 + } else { 3566 + int ret = reset_control_deassert(sport->rstc); 3567 + 3568 + if (ret) 3569 + return ret; 3570 + } 3571 + 3645 3572 uart_resume_port(&sci_uart_driver, &sport->port); 3573 + } 3646 3574 3647 3575 return 0; 3648 3576 }
+2 -4
drivers/tty/serial/stm32-usart.c
··· 944 944 945 945 static void stm32_usart_disable_ms(struct uart_port *port) 946 946 { 947 - mctrl_gpio_disable_ms(to_stm32_port(port)->gpios); 947 + mctrl_gpio_disable_ms_sync(to_stm32_port(port)->gpios); 948 948 } 949 949 950 950 /* Transmit stop */ ··· 965 965 { 966 966 struct tty_port *tport = &port->state->port; 967 967 968 - if (kfifo_is_empty(&tport->xmit_fifo) && !port->x_char) { 969 - stm32_usart_rs485_rts_disable(port); 968 + if (kfifo_is_empty(&tport->xmit_fifo) && !port->x_char) 970 969 return; 971 - } 972 970 973 971 stm32_usart_rs485_rts_enable(port); 974 972
+77 -101
drivers/tty/serial/sunsu.c
··· 151 151 } 152 152 153 153 /* 154 - * We used to support using pause I/O for certain machines. We 155 - * haven't supported this for a while, but just in case it's badly 156 - * needed for certain old 386 machines, I've left these #define's 157 - * in.... 158 - */ 159 - #define serial_inp(up, offset) serial_in(up, offset) 160 - #define serial_outp(up, offset, value) serial_out(up, offset, value) 161 - 162 - 163 - /* 164 154 * For the 16C950 165 155 */ 166 156 static void serial_icr_write(struct uart_sunsu_port *up, int offset, int value) ··· 158 168 serial_out(up, UART_SCR, offset); 159 169 serial_out(up, UART_ICR, value); 160 170 } 161 - 162 - #if 0 /* Unused currently */ 163 - static unsigned int serial_icr_read(struct uart_sunsu_port *up, int offset) 164 - { 165 - unsigned int value; 166 - 167 - serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD); 168 - serial_out(up, UART_SCR, offset); 169 - value = serial_in(up, UART_ICR); 170 - serial_icr_write(up, UART_ACR, up->acr); 171 - 172 - return value; 173 - } 174 - #endif 175 171 176 172 #ifdef CONFIG_SERIAL_8250_RSA 177 173 /* ··· 169 193 unsigned char mode; 170 194 int result; 171 195 172 - mode = serial_inp(up, UART_RSA_MSR); 196 + mode = serial_in(up, UART_RSA_MSR); 173 197 result = mode & UART_RSA_MSR_FIFO; 174 198 175 199 if (!result) { 176 - serial_outp(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); 177 - mode = serial_inp(up, UART_RSA_MSR); 200 + serial_out(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO); 201 + mode = serial_in(up, UART_RSA_MSR); 178 202 result = mode & UART_RSA_MSR_FIFO; 179 203 } 180 204 ··· 193 217 uart_port_unlock_irq(&up->port); 194 218 } 195 219 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) 196 - serial_outp(up, UART_RSA_FRR, 0); 220 + serial_out(up, UART_RSA_FRR, 0); 197 221 } 198 222 } 199 223 ··· 212 236 up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) { 213 237 uart_port_lock_irq(&up->port); 214 238 215 - mode = serial_inp(up, UART_RSA_MSR); 239 + mode = serial_in(up, UART_RSA_MSR); 216 240 result = !(mode & UART_RSA_MSR_FIFO); 217 241 218 242 if (!result) { 219 - serial_outp(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); 220 - mode = serial_inp(up, UART_RSA_MSR); 243 + serial_out(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO); 244 + mode = serial_in(up, UART_RSA_MSR); 221 245 result = !(mode & UART_RSA_MSR_FIFO); 222 246 } 223 247 ··· 302 326 int saw_console_brk = 0; 303 327 304 328 do { 305 - ch = serial_inp(up, UART_RX); 329 + ch = serial_in(up, UART_RX); 306 330 flag = TTY_NORMAL; 307 331 up->port.icount.rx++; 308 332 ··· 363 387 */ 364 388 tty_insert_flip_char(port, 0, TTY_OVERRUN); 365 389 ignore_char: 366 - *status = serial_inp(up, UART_LSR); 390 + *status = serial_in(up, UART_LSR); 367 391 } while ((*status & UART_LSR_DR) && (max_count-- > 0)); 368 392 369 393 if (saw_console_brk) ··· 377 401 int count; 378 402 379 403 if (up->port.x_char) { 380 - serial_outp(up, UART_TX, up->port.x_char); 404 + serial_out(up, UART_TX, up->port.x_char); 381 405 up->port.icount.tx++; 382 406 up->port.x_char = 0; 383 407 return; ··· 436 460 uart_port_lock_irqsave(&up->port, &flags); 437 461 438 462 do { 439 - status = serial_inp(up, UART_LSR); 463 + status = serial_in(up, UART_LSR); 440 464 if (status & UART_LSR_DR) 441 465 receive_chars(up, &status); 442 466 check_modem_status(up); ··· 474 498 static void receive_kbd_ms_chars(struct uart_sunsu_port *up, int is_break) 475 499 { 476 500 do { 477 - unsigned char ch = serial_inp(up, UART_RX); 501 + unsigned char ch = serial_in(up, UART_RX); 478 502 479 503 /* Stop-A is handled by drivers/char/keyboard.c now. */ 480 504 if (up->su_type == SU_PORT_KBD) { ··· 506 530 struct uart_sunsu_port *up = dev_id; 507 531 508 532 if (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT)) { 509 - unsigned char status = serial_inp(up, UART_LSR); 533 + unsigned char status = serial_in(up, UART_LSR); 510 534 511 535 if ((status & UART_LSR_DR) || (status & UART_LSR_BI)) 512 536 receive_kbd_ms_chars(up, (status & UART_LSR_BI) != 0); ··· 595 619 if (up->port.type == PORT_16C950) { 596 620 /* Wake up and initialize UART */ 597 621 up->acr = 0; 598 - serial_outp(up, UART_LCR, 0xBF); 599 - serial_outp(up, UART_EFR, UART_EFR_ECB); 600 - serial_outp(up, UART_IER, 0); 601 - serial_outp(up, UART_LCR, 0); 622 + serial_out(up, UART_LCR, 0xBF); 623 + serial_out(up, UART_EFR, UART_EFR_ECB); 624 + serial_out(up, UART_IER, 0); 625 + serial_out(up, UART_LCR, 0); 602 626 serial_icr_write(up, UART_CSR, 0); /* Reset the UART */ 603 - serial_outp(up, UART_LCR, 0xBF); 604 - serial_outp(up, UART_EFR, UART_EFR_ECB); 605 - serial_outp(up, UART_LCR, 0); 627 + serial_out(up, UART_LCR, 0xBF); 628 + serial_out(up, UART_EFR, UART_EFR_ECB); 629 + serial_out(up, UART_LCR, 0); 606 630 } 607 631 608 632 #ifdef CONFIG_SERIAL_8250_RSA ··· 618 642 * (they will be reenabled in set_termios()) 619 643 */ 620 644 if (uart_config[up->port.type].flags & UART_CLEAR_FIFO) { 621 - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); 622 - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | 645 + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 646 + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | 623 647 UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); 624 - serial_outp(up, UART_FCR, 0); 648 + serial_out(up, UART_FCR, 0); 625 649 } 626 650 627 651 /* 628 652 * Clear the interrupt registers. 629 653 */ 630 - (void) serial_inp(up, UART_LSR); 631 - (void) serial_inp(up, UART_RX); 632 - (void) serial_inp(up, UART_IIR); 633 - (void) serial_inp(up, UART_MSR); 654 + (void) serial_in(up, UART_LSR); 655 + (void) serial_in(up, UART_RX); 656 + (void) serial_in(up, UART_IIR); 657 + (void) serial_in(up, UART_MSR); 634 658 635 659 /* 636 660 * At this point, there's no way the LSR could still be 0xff; ··· 638 662 * here. 639 663 */ 640 664 if (!(up->port.flags & UPF_BUGGY_UART) && 641 - (serial_inp(up, UART_LSR) == 0xff)) { 665 + (serial_in(up, UART_LSR) == 0xff)) { 642 666 printk("ttyS%d: LSR safety check engaged!\n", up->port.line); 643 667 return -ENODEV; 644 668 } ··· 658 682 /* 659 683 * Now, initialize the UART 660 684 */ 661 - serial_outp(up, UART_LCR, UART_LCR_WLEN8); 685 + serial_out(up, UART_LCR, UART_LCR_WLEN8); 662 686 663 687 uart_port_lock_irqsave(&up->port, &flags); 664 688 ··· 673 697 * anyway, so we don't enable them here. 674 698 */ 675 699 up->ier = UART_IER_RLSI | UART_IER_RDI; 676 - serial_outp(up, UART_IER, up->ier); 700 + serial_out(up, UART_IER, up->ier); 677 701 678 702 if (up->port.flags & UPF_FOURPORT) { 679 703 unsigned int icp; ··· 688 712 /* 689 713 * And clear the interrupt registers again for luck. 690 714 */ 691 - (void) serial_inp(up, UART_LSR); 692 - (void) serial_inp(up, UART_RX); 693 - (void) serial_inp(up, UART_IIR); 694 - (void) serial_inp(up, UART_MSR); 715 + (void) serial_in(up, UART_LSR); 716 + (void) serial_in(up, UART_RX); 717 + (void) serial_in(up, UART_IIR); 718 + (void) serial_in(up, UART_MSR); 695 719 696 720 return 0; 697 721 } ··· 706 730 * Disable interrupts from this port 707 731 */ 708 732 up->ier = 0; 709 - serial_outp(up, UART_IER, 0); 733 + serial_out(up, UART_IER, 0); 710 734 711 735 uart_port_lock_irqsave(&up->port, &flags); 712 736 if (up->port.flags & UPF_FOURPORT) { ··· 722 746 /* 723 747 * Disable break condition and FIFOs 724 748 */ 725 - serial_out(up, UART_LCR, serial_inp(up, UART_LCR) & ~UART_LCR_SBC); 726 - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | 749 + serial_out(up, UART_LCR, serial_in(up, UART_LCR) & ~UART_LCR_SBC); 750 + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | 727 751 UART_FCR_CLEAR_RCVR | 728 752 UART_FCR_CLEAR_XMIT); 729 - serial_outp(up, UART_FCR, 0); 753 + serial_out(up, UART_FCR, 0); 730 754 731 755 #ifdef CONFIG_SERIAL_8250_RSA 732 756 /* ··· 848 872 serial_out(up, UART_IER, up->ier); 849 873 850 874 if (uart_config[up->port.type].flags & UART_STARTECH) { 851 - serial_outp(up, UART_LCR, 0xBF); 852 - serial_outp(up, UART_EFR, cflag & CRTSCTS ? UART_EFR_CTS :0); 875 + serial_out(up, UART_LCR, 0xBF); 876 + serial_out(up, UART_EFR, cflag & CRTSCTS ? UART_EFR_CTS :0); 853 877 } 854 - serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ 855 - serial_outp(up, UART_DLL, quot & 0xff); /* LS of divisor */ 856 - serial_outp(up, UART_DLM, quot >> 8); /* MS of divisor */ 878 + serial_out(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ 879 + serial_out(up, UART_DLL, quot & 0xff); /* LS of divisor */ 880 + serial_out(up, UART_DLM, quot >> 8); /* MS of divisor */ 857 881 if (up->port.type == PORT_16750) 858 - serial_outp(up, UART_FCR, fcr); /* set fcr */ 859 - serial_outp(up, UART_LCR, cval); /* reset DLAB */ 882 + serial_out(up, UART_FCR, fcr); /* set fcr */ 883 + serial_out(up, UART_LCR, cval); /* reset DLAB */ 860 884 up->lcr = cval; /* Save LCR */ 861 885 if (up->port.type != PORT_16750) { 862 886 if (fcr & UART_FCR_ENABLE_FIFO) { 863 887 /* emulated UARTs (Lucent Venus 167x) need two steps */ 864 - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); 888 + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 865 889 } 866 - serial_outp(up, UART_FCR, fcr); /* set fcr */ 890 + serial_out(up, UART_FCR, fcr); /* set fcr */ 867 891 } 868 892 869 893 up->cflag = cflag; ··· 1027 1051 * 0x80 is a non-existent port; which should be safe since 1028 1052 * include/asm/io.h also makes this assumption. 1029 1053 */ 1030 - scratch = serial_inp(up, UART_IER); 1031 - serial_outp(up, UART_IER, 0); 1054 + scratch = serial_in(up, UART_IER); 1055 + serial_out(up, UART_IER, 0); 1032 1056 #ifdef __i386__ 1033 1057 outb(0xff, 0x080); 1034 1058 #endif 1035 - scratch2 = serial_inp(up, UART_IER); 1036 - serial_outp(up, UART_IER, 0x0f); 1059 + scratch2 = serial_in(up, UART_IER); 1060 + serial_out(up, UART_IER, 0x0f); 1037 1061 #ifdef __i386__ 1038 1062 outb(0, 0x080); 1039 1063 #endif 1040 - scratch3 = serial_inp(up, UART_IER); 1041 - serial_outp(up, UART_IER, scratch); 1064 + scratch3 = serial_in(up, UART_IER); 1065 + serial_out(up, UART_IER, scratch); 1042 1066 if (scratch2 != 0 || scratch3 != 0x0F) 1043 1067 goto out; /* We failed; there's nothing here */ 1044 1068 } ··· 1056 1080 * that conflicts with COM 1-4 --- we hope! 1057 1081 */ 1058 1082 if (!(up->port.flags & UPF_SKIP_TEST)) { 1059 - serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A); 1060 - status1 = serial_inp(up, UART_MSR) & 0xF0; 1061 - serial_outp(up, UART_MCR, save_mcr); 1083 + serial_out(up, UART_MCR, UART_MCR_LOOP | 0x0A); 1084 + status1 = serial_in(up, UART_MSR) & 0xF0; 1085 + serial_out(up, UART_MCR, save_mcr); 1062 1086 if (status1 != 0x90) 1063 1087 goto out; /* We failed loopback test */ 1064 1088 } 1065 - serial_outp(up, UART_LCR, 0xBF); /* set up for StarTech test */ 1066 - serial_outp(up, UART_EFR, 0); /* EFR is the same as FCR */ 1067 - serial_outp(up, UART_LCR, 0); 1068 - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1089 + serial_out(up, UART_LCR, 0xBF); /* set up for StarTech test */ 1090 + serial_out(up, UART_EFR, 0); /* EFR is the same as FCR */ 1091 + serial_out(up, UART_LCR, 0); 1092 + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1069 1093 scratch = serial_in(up, UART_IIR) >> 6; 1070 1094 switch (scratch) { 1071 1095 case 0: ··· 1083 1107 } 1084 1108 if (up->port.type == PORT_16550A) { 1085 1109 /* Check for Startech UART's */ 1086 - serial_outp(up, UART_LCR, UART_LCR_DLAB); 1110 + serial_out(up, UART_LCR, UART_LCR_DLAB); 1087 1111 if (serial_in(up, UART_EFR) == 0) { 1088 1112 up->port.type = PORT_16650; 1089 1113 } else { 1090 - serial_outp(up, UART_LCR, 0xBF); 1114 + serial_out(up, UART_LCR, 0xBF); 1091 1115 if (serial_in(up, UART_EFR) == 0) 1092 1116 up->port.type = PORT_16650V2; 1093 1117 } 1094 1118 } 1095 1119 if (up->port.type == PORT_16550A) { 1096 1120 /* Check for TI 16750 */ 1097 - serial_outp(up, UART_LCR, save_lcr | UART_LCR_DLAB); 1098 - serial_outp(up, UART_FCR, 1121 + serial_out(up, UART_LCR, save_lcr | UART_LCR_DLAB); 1122 + serial_out(up, UART_FCR, 1099 1123 UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); 1100 1124 scratch = serial_in(up, UART_IIR) >> 5; 1101 1125 if (scratch == 7) { ··· 1105 1129 * mode if the UART_FCR7_64BYTE bit was set 1106 1130 * while UART_LCR_DLAB was latched. 1107 1131 */ 1108 - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1109 - serial_outp(up, UART_LCR, 0); 1110 - serial_outp(up, UART_FCR, 1132 + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1133 + serial_out(up, UART_LCR, 0); 1134 + serial_out(up, UART_FCR, 1111 1135 UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); 1112 1136 scratch = serial_in(up, UART_IIR) >> 5; 1113 1137 if (scratch == 6) 1114 1138 up->port.type = PORT_16750; 1115 1139 } 1116 - serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1140 + serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 1117 1141 } 1118 - serial_outp(up, UART_LCR, save_lcr); 1142 + serial_out(up, UART_LCR, save_lcr); 1119 1143 if (up->port.type == PORT_16450) { 1120 1144 scratch = serial_in(up, UART_SCR); 1121 - serial_outp(up, UART_SCR, 0xa5); 1145 + serial_out(up, UART_SCR, 0xa5); 1122 1146 status1 = serial_in(up, UART_SCR); 1123 - serial_outp(up, UART_SCR, 0x5a); 1147 + serial_out(up, UART_SCR, 0x5a); 1124 1148 status2 = serial_in(up, UART_SCR); 1125 - serial_outp(up, UART_SCR, scratch); 1149 + serial_out(up, UART_SCR, scratch); 1126 1150 1127 1151 if ((status1 != 0xa5) || (status2 != 0x5a)) 1128 1152 up->port.type = PORT_8250; ··· 1139 1163 */ 1140 1164 #ifdef CONFIG_SERIAL_8250_RSA 1141 1165 if (up->port.type == PORT_RSA) 1142 - serial_outp(up, UART_RSA_FRR, 0); 1166 + serial_out(up, UART_RSA_FRR, 0); 1143 1167 #endif 1144 - serial_outp(up, UART_MCR, save_mcr); 1145 - serial_outp(up, UART_FCR, (UART_FCR_ENABLE_FIFO | 1168 + serial_out(up, UART_MCR, save_mcr); 1169 + serial_out(up, UART_FCR, (UART_FCR_ENABLE_FIFO | 1146 1170 UART_FCR_CLEAR_RCVR | 1147 1171 UART_FCR_CLEAR_XMIT)); 1148 - serial_outp(up, UART_FCR, 0); 1172 + serial_out(up, UART_FCR, 0); 1149 1173 (void)serial_in(up, UART_RX); 1150 - serial_outp(up, UART_IER, 0); 1174 + serial_out(up, UART_IER, 0); 1151 1175 1152 1176 out: 1153 1177 uart_port_unlock_irqrestore(&up->port, flags);
+625
drivers/tty/serial/tegra-utc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + // SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 + // NVIDIA Tegra UTC (UART Trace Controller) driver. 4 + 5 + #include <linux/bits.h> 6 + #include <linux/console.h> 7 + #include <linux/container_of.h> 8 + #include <linux/device.h> 9 + #include <linux/err.h> 10 + #include <linux/iopoll.h> 11 + #include <linux/kfifo.h> 12 + #include <linux/module.h> 13 + #include <linux/mod_devicetable.h> 14 + #include <linux/property.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/serial.h> 17 + #include <linux/serial_core.h> 18 + #include <linux/slab.h> 19 + #include <linux/tty.h> 20 + #include <linux/tty_flip.h> 21 + #include <linux/types.h> 22 + 23 + #define TEGRA_UTC_ENABLE 0x000 24 + #define TEGRA_UTC_ENABLE_CLIENT_ENABLE BIT(0) 25 + 26 + #define TEGRA_UTC_FIFO_THRESHOLD 0x008 27 + 28 + #define TEGRA_UTC_COMMAND 0x00c 29 + #define TEGRA_UTC_COMMAND_RESET BIT(0) 30 + #define TEGRA_UTC_COMMAND_FLUSH BIT(1) 31 + 32 + #define TEGRA_UTC_DATA 0x020 33 + 34 + #define TEGRA_UTC_FIFO_STATUS 0x100 35 + #define TEGRA_UTC_FIFO_EMPTY BIT(0) 36 + #define TEGRA_UTC_FIFO_FULL BIT(1) 37 + #define TEGRA_UTC_FIFO_REQ BIT(2) 38 + #define TEGRA_UTC_FIFO_OVERFLOW BIT(3) 39 + #define TEGRA_UTC_FIFO_TIMEOUT BIT(4) 40 + 41 + #define TEGRA_UTC_FIFO_OCCUPANCY 0x104 42 + 43 + #define TEGRA_UTC_INTR_STATUS 0x108 44 + #define TEGRA_UTC_INTR_SET 0x10c 45 + #define TEGRA_UTC_INTR_MASK 0x110 46 + #define TEGRA_UTC_INTR_CLEAR 0x114 47 + #define TEGRA_UTC_INTR_EMPTY BIT(0) 48 + #define TEGRA_UTC_INTR_FULL BIT(1) 49 + #define TEGRA_UTC_INTR_REQ BIT(2) 50 + #define TEGRA_UTC_INTR_OVERFLOW BIT(3) 51 + #define TEGRA_UTC_INTR_TIMEOUT BIT(4) 52 + 53 + #define TEGRA_UTC_UART_NR 16 54 + 55 + #define TEGRA_UTC_INTR_COMMON (TEGRA_UTC_INTR_REQ | TEGRA_UTC_INTR_FULL | TEGRA_UTC_INTR_EMPTY) 56 + 57 + struct tegra_utc_port { 58 + #if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) 59 + struct console console; 60 + #endif 61 + struct uart_port port; 62 + 63 + void __iomem *rx_base; 64 + void __iomem *tx_base; 65 + 66 + u32 tx_irqmask; 67 + u32 rx_irqmask; 68 + 69 + unsigned int fifosize; 70 + u32 tx_threshold; 71 + u32 rx_threshold; 72 + }; 73 + 74 + static u32 tegra_utc_rx_readl(struct tegra_utc_port *tup, unsigned int offset) 75 + { 76 + void __iomem *addr = tup->rx_base + offset; 77 + 78 + return readl_relaxed(addr); 79 + } 80 + 81 + static void tegra_utc_rx_writel(struct tegra_utc_port *tup, u32 val, unsigned int offset) 82 + { 83 + void __iomem *addr = tup->rx_base + offset; 84 + 85 + writel_relaxed(val, addr); 86 + } 87 + 88 + static u32 tegra_utc_tx_readl(struct tegra_utc_port *tup, unsigned int offset) 89 + { 90 + void __iomem *addr = tup->tx_base + offset; 91 + 92 + return readl_relaxed(addr); 93 + } 94 + 95 + static void tegra_utc_tx_writel(struct tegra_utc_port *tup, u32 val, unsigned int offset) 96 + { 97 + void __iomem *addr = tup->tx_base + offset; 98 + 99 + writel_relaxed(val, addr); 100 + } 101 + 102 + static void tegra_utc_enable_tx_irq(struct tegra_utc_port *tup) 103 + { 104 + tup->tx_irqmask = TEGRA_UTC_INTR_REQ; 105 + 106 + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_MASK); 107 + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_SET); 108 + } 109 + 110 + static void tegra_utc_disable_tx_irq(struct tegra_utc_port *tup) 111 + { 112 + tup->tx_irqmask = 0x0; 113 + 114 + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_MASK); 115 + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_SET); 116 + } 117 + 118 + static void tegra_utc_stop_tx(struct uart_port *port) 119 + { 120 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 121 + 122 + tegra_utc_disable_tx_irq(tup); 123 + } 124 + 125 + static void tegra_utc_init_tx(struct tegra_utc_port *tup) 126 + { 127 + /* Disable TX. */ 128 + tegra_utc_tx_writel(tup, 0x0, TEGRA_UTC_ENABLE); 129 + 130 + /* Update the FIFO Threshold. */ 131 + tegra_utc_tx_writel(tup, tup->tx_threshold, TEGRA_UTC_FIFO_THRESHOLD); 132 + 133 + /* Clear and mask all the interrupts. */ 134 + tegra_utc_tx_writel(tup, TEGRA_UTC_INTR_COMMON, TEGRA_UTC_INTR_CLEAR); 135 + tegra_utc_disable_tx_irq(tup); 136 + 137 + /* Enable TX. */ 138 + tegra_utc_tx_writel(tup, TEGRA_UTC_ENABLE_CLIENT_ENABLE, TEGRA_UTC_ENABLE); 139 + } 140 + 141 + static void tegra_utc_init_rx(struct tegra_utc_port *tup) 142 + { 143 + tup->rx_irqmask = TEGRA_UTC_INTR_REQ | TEGRA_UTC_INTR_TIMEOUT; 144 + 145 + tegra_utc_rx_writel(tup, TEGRA_UTC_COMMAND_RESET, TEGRA_UTC_COMMAND); 146 + tegra_utc_rx_writel(tup, tup->rx_threshold, TEGRA_UTC_FIFO_THRESHOLD); 147 + 148 + /* Clear all the pending interrupts. */ 149 + tegra_utc_rx_writel(tup, TEGRA_UTC_INTR_TIMEOUT | TEGRA_UTC_INTR_OVERFLOW | 150 + TEGRA_UTC_INTR_COMMON, TEGRA_UTC_INTR_CLEAR); 151 + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_MASK); 152 + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_SET); 153 + 154 + /* Enable RX. */ 155 + tegra_utc_rx_writel(tup, TEGRA_UTC_ENABLE_CLIENT_ENABLE, TEGRA_UTC_ENABLE); 156 + } 157 + 158 + static bool tegra_utc_tx_chars(struct tegra_utc_port *tup) 159 + { 160 + struct uart_port *port = &tup->port; 161 + unsigned int pending; 162 + u8 c; 163 + 164 + pending = uart_port_tx(port, c, 165 + !(tegra_utc_tx_readl(tup, TEGRA_UTC_FIFO_STATUS) & TEGRA_UTC_FIFO_FULL), 166 + tegra_utc_tx_writel(tup, c, TEGRA_UTC_DATA)); 167 + 168 + return pending; 169 + } 170 + 171 + static void tegra_utc_rx_chars(struct tegra_utc_port *tup) 172 + { 173 + struct tty_port *port = &tup->port.state->port; 174 + unsigned int max_chars = 256; 175 + u32 status; 176 + int sysrq; 177 + u32 ch; 178 + 179 + while (max_chars--) { 180 + status = tegra_utc_rx_readl(tup, TEGRA_UTC_FIFO_STATUS); 181 + if (status & TEGRA_UTC_FIFO_EMPTY) 182 + break; 183 + 184 + ch = tegra_utc_rx_readl(tup, TEGRA_UTC_DATA); 185 + tup->port.icount.rx++; 186 + 187 + if (status & TEGRA_UTC_FIFO_OVERFLOW) 188 + tup->port.icount.overrun++; 189 + 190 + uart_port_unlock(&tup->port); 191 + sysrq = uart_handle_sysrq_char(&tup->port, ch); 192 + uart_port_lock(&tup->port); 193 + 194 + if (!sysrq) 195 + tty_insert_flip_char(port, ch, TTY_NORMAL); 196 + } 197 + 198 + tty_flip_buffer_push(port); 199 + } 200 + 201 + static irqreturn_t tegra_utc_isr(int irq, void *dev_id) 202 + { 203 + struct tegra_utc_port *tup = dev_id; 204 + unsigned int handled = 0; 205 + u32 status; 206 + 207 + uart_port_lock(&tup->port); 208 + 209 + /* Process RX_REQ and RX_TIMEOUT interrupts. */ 210 + do { 211 + status = tegra_utc_rx_readl(tup, TEGRA_UTC_INTR_STATUS) & tup->rx_irqmask; 212 + if (status) { 213 + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_CLEAR); 214 + tegra_utc_rx_chars(tup); 215 + handled = 1; 216 + } 217 + } while (status); 218 + 219 + /* Process TX_REQ interrupt. */ 220 + do { 221 + status = tegra_utc_tx_readl(tup, TEGRA_UTC_INTR_STATUS) & tup->tx_irqmask; 222 + if (status) { 223 + tegra_utc_tx_writel(tup, tup->tx_irqmask, TEGRA_UTC_INTR_CLEAR); 224 + tegra_utc_tx_chars(tup); 225 + handled = 1; 226 + } 227 + } while (status); 228 + 229 + uart_port_unlock(&tup->port); 230 + 231 + return IRQ_RETVAL(handled); 232 + } 233 + 234 + static unsigned int tegra_utc_tx_empty(struct uart_port *port) 235 + { 236 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 237 + 238 + return tegra_utc_tx_readl(tup, TEGRA_UTC_FIFO_OCCUPANCY) ? 0 : TIOCSER_TEMT; 239 + } 240 + 241 + static void tegra_utc_set_mctrl(struct uart_port *port, unsigned int mctrl) 242 + { 243 + } 244 + 245 + static unsigned int tegra_utc_get_mctrl(struct uart_port *port) 246 + { 247 + return 0; 248 + } 249 + 250 + static void tegra_utc_start_tx(struct uart_port *port) 251 + { 252 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 253 + 254 + if (tegra_utc_tx_chars(tup)) 255 + tegra_utc_enable_tx_irq(tup); 256 + } 257 + 258 + static void tegra_utc_stop_rx(struct uart_port *port) 259 + { 260 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 261 + 262 + tup->rx_irqmask = 0x0; 263 + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_MASK); 264 + tegra_utc_rx_writel(tup, tup->rx_irqmask, TEGRA_UTC_INTR_SET); 265 + } 266 + 267 + static void tegra_utc_hw_init(struct tegra_utc_port *tup) 268 + { 269 + tegra_utc_init_tx(tup); 270 + tegra_utc_init_rx(tup); 271 + } 272 + 273 + static int tegra_utc_startup(struct uart_port *port) 274 + { 275 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 276 + int ret; 277 + 278 + tegra_utc_hw_init(tup); 279 + 280 + /* Interrupt is dedicated to this UTC client. */ 281 + ret = request_irq(port->irq, tegra_utc_isr, 0, dev_name(port->dev), tup); 282 + if (ret < 0) 283 + dev_err(port->dev, "failed to register interrupt handler\n"); 284 + 285 + return ret; 286 + } 287 + 288 + static void tegra_utc_shutdown(struct uart_port *port) 289 + { 290 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 291 + 292 + tegra_utc_rx_writel(tup, 0x0, TEGRA_UTC_ENABLE); 293 + free_irq(port->irq, tup); 294 + } 295 + 296 + static void tegra_utc_set_termios(struct uart_port *port, struct ktermios *termios, 297 + const struct ktermios *old) 298 + { 299 + /* The Tegra UTC clients supports only 8-N-1 configuration without HW flow control */ 300 + termios->c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD); 301 + termios->c_cflag &= ~(CMSPAR | CRTSCTS); 302 + termios->c_cflag |= CS8 | CLOCAL; 303 + } 304 + 305 + #ifdef CONFIG_CONSOLE_POLL 306 + 307 + static int tegra_utc_poll_init(struct uart_port *port) 308 + { 309 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 310 + 311 + tegra_utc_hw_init(tup); 312 + return 0; 313 + } 314 + 315 + static int tegra_utc_get_poll_char(struct uart_port *port) 316 + { 317 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 318 + 319 + if (tegra_utc_rx_readl(tup, TEGRA_UTC_FIFO_STATUS) & TEGRA_UTC_FIFO_EMPTY) 320 + return NO_POLL_CHAR; 321 + 322 + return tegra_utc_rx_readl(tup, TEGRA_UTC_DATA); 323 + } 324 + 325 + static void tegra_utc_put_poll_char(struct uart_port *port, unsigned char ch) 326 + { 327 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 328 + u32 val; 329 + 330 + read_poll_timeout_atomic(tegra_utc_tx_readl, val, !(val & TEGRA_UTC_FIFO_FULL), 331 + 0, USEC_PER_SEC, false, tup, TEGRA_UTC_FIFO_STATUS); 332 + 333 + tegra_utc_tx_writel(tup, ch, TEGRA_UTC_DATA); 334 + } 335 + 336 + #endif 337 + 338 + static const struct uart_ops tegra_utc_uart_ops = { 339 + .tx_empty = tegra_utc_tx_empty, 340 + .set_mctrl = tegra_utc_set_mctrl, 341 + .get_mctrl = tegra_utc_get_mctrl, 342 + .stop_tx = tegra_utc_stop_tx, 343 + .start_tx = tegra_utc_start_tx, 344 + .stop_rx = tegra_utc_stop_rx, 345 + .startup = tegra_utc_startup, 346 + .shutdown = tegra_utc_shutdown, 347 + .set_termios = tegra_utc_set_termios, 348 + #ifdef CONFIG_CONSOLE_POLL 349 + .poll_init = tegra_utc_poll_init, 350 + .poll_get_char = tegra_utc_get_poll_char, 351 + .poll_put_char = tegra_utc_put_poll_char, 352 + #endif 353 + }; 354 + 355 + #if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) 356 + #define TEGRA_UTC_DEFAULT_FIFO_THRESHOLD 4 357 + #define TEGRA_UTC_EARLYCON_MAX_BURST_SIZE 128 358 + 359 + static void tegra_utc_putc(struct uart_port *port, unsigned char c) 360 + { 361 + writel(c, port->membase + TEGRA_UTC_DATA); 362 + } 363 + 364 + static void tegra_utc_early_write(struct console *con, const char *s, unsigned int n) 365 + { 366 + struct earlycon_device *dev = con->data; 367 + 368 + while (n) { 369 + u32 burst_size = TEGRA_UTC_EARLYCON_MAX_BURST_SIZE; 370 + 371 + burst_size -= readl(dev->port.membase + TEGRA_UTC_FIFO_OCCUPANCY); 372 + if (n < burst_size) 373 + burst_size = n; 374 + 375 + uart_console_write(&dev->port, s, burst_size, tegra_utc_putc); 376 + 377 + n -= burst_size; 378 + s += burst_size; 379 + } 380 + } 381 + 382 + static int __init tegra_utc_early_console_setup(struct earlycon_device *device, const char *opt) 383 + { 384 + if (!device->port.membase) 385 + return -ENODEV; 386 + 387 + /* Configure TX */ 388 + writel(TEGRA_UTC_COMMAND_FLUSH | TEGRA_UTC_COMMAND_RESET, 389 + device->port.membase + TEGRA_UTC_COMMAND); 390 + writel(TEGRA_UTC_DEFAULT_FIFO_THRESHOLD, device->port.membase + TEGRA_UTC_FIFO_THRESHOLD); 391 + 392 + /* Clear and mask all the interrupts. */ 393 + writel(TEGRA_UTC_INTR_COMMON, device->port.membase + TEGRA_UTC_INTR_CLEAR); 394 + 395 + writel(0x0, device->port.membase + TEGRA_UTC_INTR_MASK); 396 + writel(0x0, device->port.membase + TEGRA_UTC_INTR_SET); 397 + 398 + /* Enable TX. */ 399 + writel(TEGRA_UTC_ENABLE_CLIENT_ENABLE, device->port.membase + TEGRA_UTC_ENABLE); 400 + 401 + device->con->write = tegra_utc_early_write; 402 + 403 + return 0; 404 + } 405 + OF_EARLYCON_DECLARE(tegra_utc, "nvidia,tegra264-utc", tegra_utc_early_console_setup); 406 + 407 + static void tegra_utc_console_putchar(struct uart_port *port, unsigned char ch) 408 + { 409 + struct tegra_utc_port *tup = container_of(port, struct tegra_utc_port, port); 410 + 411 + tegra_utc_tx_writel(tup, ch, TEGRA_UTC_DATA); 412 + } 413 + 414 + static void tegra_utc_console_write_atomic(struct console *cons, struct nbcon_write_context *wctxt) 415 + { 416 + struct tegra_utc_port *tup = container_of(cons, struct tegra_utc_port, console); 417 + unsigned int len; 418 + char *outbuf; 419 + 420 + if (!nbcon_enter_unsafe(wctxt)) 421 + return; 422 + 423 + outbuf = wctxt->outbuf; 424 + len = wctxt->len; 425 + 426 + while (len) { 427 + u32 burst_size = tup->fifosize; 428 + 429 + burst_size -= tegra_utc_tx_readl(tup, TEGRA_UTC_FIFO_OCCUPANCY); 430 + if (len < burst_size) 431 + burst_size = len; 432 + 433 + uart_console_write(&tup->port, outbuf, burst_size, tegra_utc_console_putchar); 434 + 435 + outbuf += burst_size; 436 + len -= burst_size; 437 + }; 438 + 439 + nbcon_exit_unsafe(wctxt); 440 + } 441 + 442 + static void tegra_utc_console_write_thread(struct console *cons, struct nbcon_write_context *wctxt) 443 + { 444 + struct tegra_utc_port *tup = container_of(cons, struct tegra_utc_port, console); 445 + unsigned int len = READ_ONCE(wctxt->len); 446 + unsigned int i; 447 + u32 val; 448 + 449 + for (i = 0; i < len; i++) { 450 + if (!nbcon_enter_unsafe(wctxt)) 451 + break; 452 + 453 + read_poll_timeout_atomic(tegra_utc_tx_readl, val, !(val & TEGRA_UTC_FIFO_FULL), 454 + 0, USEC_PER_SEC, false, tup, TEGRA_UTC_FIFO_STATUS); 455 + uart_console_write(&tup->port, wctxt->outbuf + i, 1, tegra_utc_console_putchar); 456 + 457 + if (!nbcon_exit_unsafe(wctxt)) 458 + break; 459 + } 460 + } 461 + 462 + static void tegra_utc_console_device_lock(struct console *cons, unsigned long *flags) 463 + { 464 + struct tegra_utc_port *tup = container_of(cons, struct tegra_utc_port, console); 465 + struct uart_port *port = &tup->port; 466 + 467 + __uart_port_lock_irqsave(port, flags); 468 + } 469 + 470 + static void tegra_utc_console_device_unlock(struct console *cons, unsigned long flags) 471 + { 472 + struct tegra_utc_port *tup = container_of(cons, struct tegra_utc_port, console); 473 + struct uart_port *port = &tup->port; 474 + 475 + __uart_port_unlock_irqrestore(port, flags); 476 + } 477 + 478 + static int tegra_utc_console_setup(struct console *cons, char *options) 479 + { 480 + struct tegra_utc_port *tup = container_of(cons, struct tegra_utc_port, console); 481 + 482 + tegra_utc_init_tx(tup); 483 + 484 + return 0; 485 + } 486 + #endif 487 + 488 + static struct uart_driver tegra_utc_driver = { 489 + .driver_name = "tegra-utc", 490 + .dev_name = "ttyUTC", 491 + .nr = TEGRA_UTC_UART_NR, 492 + }; 493 + 494 + static int tegra_utc_setup_port(struct device *dev, struct tegra_utc_port *tup) 495 + { 496 + tup->port.dev = dev; 497 + tup->port.fifosize = tup->fifosize; 498 + tup->port.flags = UPF_BOOT_AUTOCONF; 499 + tup->port.iotype = UPIO_MEM; 500 + tup->port.ops = &tegra_utc_uart_ops; 501 + tup->port.type = PORT_TEGRA_TCU; 502 + tup->port.private_data = tup; 503 + 504 + #if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) 505 + strscpy(tup->console.name, "ttyUTC", sizeof(tup->console.name)); 506 + tup->console.write_atomic = tegra_utc_console_write_atomic; 507 + tup->console.write_thread = tegra_utc_console_write_thread; 508 + tup->console.device_lock = tegra_utc_console_device_lock; 509 + tup->console.device_unlock = tegra_utc_console_device_unlock; 510 + tup->console.device = uart_console_device; 511 + tup->console.setup = tegra_utc_console_setup; 512 + tup->console.flags = CON_PRINTBUFFER | CON_NBCON; 513 + tup->console.data = &tegra_utc_driver; 514 + #endif 515 + 516 + return uart_read_port_properties(&tup->port); 517 + } 518 + 519 + static int tegra_utc_register_port(struct tegra_utc_port *tup) 520 + { 521 + int ret; 522 + 523 + ret = uart_add_one_port(&tegra_utc_driver, &tup->port); 524 + if (ret) 525 + return ret; 526 + 527 + #if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) 528 + register_console(&tup->console); 529 + #endif 530 + 531 + return 0; 532 + } 533 + 534 + static int tegra_utc_probe(struct platform_device *pdev) 535 + { 536 + const unsigned int *soc_fifosize; 537 + struct device *dev = &pdev->dev; 538 + struct tegra_utc_port *tup; 539 + int ret; 540 + 541 + tup = devm_kzalloc(dev, sizeof(*tup), GFP_KERNEL); 542 + if (!tup) 543 + return -ENOMEM; 544 + 545 + ret = device_property_read_u32(dev, "tx-threshold", &tup->tx_threshold); 546 + if (ret) 547 + return dev_err_probe(dev, ret, "missing %s property\n", "tx-threshold"); 548 + 549 + ret = device_property_read_u32(dev, "rx-threshold", &tup->rx_threshold); 550 + if (ret) 551 + return dev_err_probe(dev, ret, "missing %s property\n", "rx-threshold"); 552 + 553 + soc_fifosize = device_get_match_data(dev); 554 + tup->fifosize = *soc_fifosize; 555 + 556 + tup->tx_base = devm_platform_ioremap_resource_byname(pdev, "tx"); 557 + if (IS_ERR(tup->tx_base)) 558 + return PTR_ERR(tup->tx_base); 559 + 560 + tup->rx_base = devm_platform_ioremap_resource_byname(pdev, "rx"); 561 + if (IS_ERR(tup->rx_base)) 562 + return PTR_ERR(tup->rx_base); 563 + 564 + ret = tegra_utc_setup_port(dev, tup); 565 + if (ret) 566 + dev_err_probe(dev, ret, "failed to setup uart port\n"); 567 + 568 + platform_set_drvdata(pdev, tup); 569 + 570 + return tegra_utc_register_port(tup); 571 + } 572 + 573 + static void tegra_utc_remove(struct platform_device *pdev) 574 + { 575 + struct tegra_utc_port *tup = platform_get_drvdata(pdev); 576 + 577 + #if IS_ENABLED(CONFIG_SERIAL_TEGRA_UTC_CONSOLE) 578 + unregister_console(&tup->console); 579 + #endif 580 + uart_remove_one_port(&tegra_utc_driver, &tup->port); 581 + } 582 + 583 + static const unsigned int tegra264_utc_soc = 128; 584 + 585 + static const struct of_device_id tegra_utc_of_match[] = { 586 + { .compatible = "nvidia,tegra264-utc", .data = &tegra264_utc_soc }, 587 + {} 588 + }; 589 + MODULE_DEVICE_TABLE(of, tegra_utc_of_match); 590 + 591 + static struct platform_driver tegra_utc_platform_driver = { 592 + .probe = tegra_utc_probe, 593 + .remove = tegra_utc_remove, 594 + .driver = { 595 + .name = "tegra-utc", 596 + .of_match_table = tegra_utc_of_match, 597 + }, 598 + }; 599 + 600 + static int __init tegra_utc_init(void) 601 + { 602 + int ret; 603 + 604 + ret = uart_register_driver(&tegra_utc_driver); 605 + if (ret) 606 + return ret; 607 + 608 + ret = platform_driver_register(&tegra_utc_platform_driver); 609 + if (ret) 610 + uart_unregister_driver(&tegra_utc_driver); 611 + 612 + return ret; 613 + } 614 + module_init(tegra_utc_init); 615 + 616 + static void __exit tegra_utc_exit(void) 617 + { 618 + platform_driver_unregister(&tegra_utc_platform_driver); 619 + uart_unregister_driver(&tegra_utc_driver); 620 + } 621 + module_exit(tegra_utc_exit); 622 + 623 + MODULE_AUTHOR("Kartik Rajput <kkartik@nvidia.com>"); 624 + MODULE_DESCRIPTION("Tegra UART Trace Controller"); 625 + MODULE_LICENSE("GPL");
+6 -4
drivers/tty/tty_audit.c
··· 12 12 #include <linux/tty.h> 13 13 #include "tty.h" 14 14 15 + #define TTY_AUDIT_BUF_SIZE 4096 16 + 15 17 struct tty_audit_buf { 16 18 struct mutex mutex; /* Protects all data below */ 17 19 dev_t dev; /* The TTY which the data is from */ 18 20 bool icanon; 19 21 size_t valid; 20 - u8 *data; /* Allocated size N_TTY_BUF_SIZE */ 22 + u8 *data; /* Allocated size TTY_AUDIT_BUF_SIZE */ 21 23 }; 22 24 23 25 static struct tty_audit_buf *tty_audit_buf_ref(void) ··· 39 37 if (!buf) 40 38 goto err; 41 39 42 - buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 40 + buf->data = kmalloc(TTY_AUDIT_BUF_SIZE, GFP_KERNEL); 43 41 if (!buf->data) 44 42 goto err_buf; 45 43 ··· 237 235 do { 238 236 size_t run; 239 237 240 - run = N_TTY_BUF_SIZE - buf->valid; 238 + run = TTY_AUDIT_BUF_SIZE - buf->valid; 241 239 if (run > size) 242 240 run = size; 243 241 memcpy(buf->data + buf->valid, data, run); 244 242 buf->valid += run; 245 243 data += run; 246 244 size -= run; 247 - if (buf->valid == N_TTY_BUF_SIZE) 245 + if (buf->valid == TTY_AUDIT_BUF_SIZE) 248 246 tty_audit_buf_push(buf); 249 247 } while (size != 0); 250 248 mutex_unlock(&buf->mutex);
+5 -3
drivers/tty/tty_io.c
··· 3329 3329 * __tty_alloc_driver - allocate tty driver 3330 3330 * @lines: count of lines this driver can handle at most 3331 3331 * @owner: module which is responsible for this driver 3332 - * @flags: some of %TTY_DRIVER_ flags, will be set in driver->flags 3332 + * @flags: some of enum tty_driver_flag, will be set in driver->flags 3333 3333 * 3334 - * This should not be called directly, some of the provided macros should be 3335 - * used instead. Use IS_ERR() and friends on @retval. 3334 + * This should not be called directly, tty_alloc_driver() should be used 3335 + * instead. 3336 + * 3337 + * Returns: struct tty_driver or a PTR-encoded error (use IS_ERR() and friends). 3336 3338 */ 3337 3339 struct tty_driver *__tty_alloc_driver(unsigned int lines, struct module *owner, 3338 3340 unsigned long flags)
-17
drivers/tty/tty_ldsem.c
··· 367 367 } 368 368 369 369 /* 370 - * trylock for writing -- returns 1 if successful, 0 if contention 371 - */ 372 - int ldsem_down_write_trylock(struct ld_semaphore *sem) 373 - { 374 - long count = atomic_long_read(&sem->count); 375 - 376 - while ((count & LDSEM_ACTIVE_MASK) == 0) { 377 - if (atomic_long_try_cmpxchg(&sem->count, &count, count + LDSEM_WRITE_BIAS)) { 378 - rwsem_acquire(&sem->dep_map, 0, 1, _RET_IP_); 379 - lock_acquired(&sem->dep_map, _RET_IP_); 380 - return 1; 381 - } 382 - } 383 - return 0; 384 - } 385 - 386 - /* 387 370 * release a read lock 388 371 */ 389 372 void ldsem_up_read(struct ld_semaphore *sem)
-11
include/linux/kgdb.h
··· 257 257 * hardware breakpoints. 258 258 * @correct_hw_break: Allow an architecture to specify how to correct the 259 259 * hardware debug registers. 260 - * @enable_nmi: Manage NMI-triggered entry to KGDB 261 260 */ 262 261 struct kgdb_arch { 263 262 unsigned char gdb_bpt_instr[BREAK_INSTR_SIZE]; ··· 269 270 void (*disable_hw_break)(struct pt_regs *regs); 270 271 void (*remove_all_hw_break)(void); 271 272 void (*correct_hw_break)(void); 272 - 273 - void (*enable_nmi)(bool on); 274 273 }; 275 274 276 275 /** ··· 302 305 extern const struct kgdb_arch arch_kgdb_ops; 303 306 304 307 extern unsigned long kgdb_arch_pc(int exception, struct pt_regs *regs); 305 - 306 - #ifdef CONFIG_SERIAL_KGDB_NMI 307 - extern int kgdb_register_nmi_console(void); 308 - extern int kgdb_unregister_nmi_console(void); 309 - #else 310 - static inline int kgdb_register_nmi_console(void) { return 0; } 311 - static inline int kgdb_unregister_nmi_console(void) { return 0; } 312 - #endif 313 308 314 309 extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops); 315 310 extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops);
-6
include/linux/serdev.h
··· 84 84 struct serdev_controller_ops { 85 85 ssize_t (*write_buf)(struct serdev_controller *, const u8 *, size_t); 86 86 void (*write_flush)(struct serdev_controller *); 87 - int (*write_room)(struct serdev_controller *); 88 87 int (*open)(struct serdev_controller *); 89 88 void (*close)(struct serdev_controller *); 90 89 void (*set_flow_control)(struct serdev_controller *, bool); ··· 211 212 void serdev_device_write_wakeup(struct serdev_device *); 212 213 ssize_t serdev_device_write(struct serdev_device *, const u8 *, size_t, long); 213 214 void serdev_device_write_flush(struct serdev_device *); 214 - int serdev_device_write_room(struct serdev_device *); 215 215 216 216 /* 217 217 * serdev device driver functions ··· 271 273 return -ENODEV; 272 274 } 273 275 static inline void serdev_device_write_flush(struct serdev_device *sdev) {} 274 - static inline int serdev_device_write_room(struct serdev_device *sdev) 275 - { 276 - return 0; 277 - } 278 276 279 277 #define serdev_device_driver_register(x) 280 278 #define serdev_device_driver_unregister(x)
+27 -26
include/linux/tty.h
··· 239 239 240 240 struct list_head tty_files; 241 241 242 - #define N_TTY_BUF_SIZE 4096 243 242 struct work_struct SAK_work; 244 243 } __randomize_layout; 245 244 ··· 250 251 }; 251 252 252 253 /** 253 - * DOC: TTY Struct Flags 254 + * enum tty_struct_flags - TTY Struct Flags 254 255 * 255 256 * These bits are used in the :c:member:`tty_struct.flags` field. 256 257 * ··· 259 260 * tty->write. Thus, you must use the inline functions set_bit() and 260 261 * clear_bit() to make things atomic. 261 262 * 262 - * TTY_THROTTLED 263 + * @TTY_THROTTLED: 263 264 * Driver input is throttled. The ldisc should call 264 265 * :c:member:`tty_driver.unthrottle()` in order to resume reception when 265 266 * it is ready to process more data (at threshold min). 266 267 * 267 - * TTY_IO_ERROR 268 + * @TTY_IO_ERROR: 268 269 * If set, causes all subsequent userspace read/write calls on the tty to 269 270 * fail, returning -%EIO. (May be no ldisc too.) 270 271 * 271 - * TTY_OTHER_CLOSED 272 + * @TTY_OTHER_CLOSED: 272 273 * Device is a pty and the other side has closed. 273 274 * 274 - * TTY_EXCLUSIVE 275 + * @TTY_EXCLUSIVE: 275 276 * Exclusive open mode (a single opener). 276 277 * 277 - * TTY_DO_WRITE_WAKEUP 278 + * @TTY_DO_WRITE_WAKEUP: 278 279 * If set, causes the driver to call the 279 280 * :c:member:`tty_ldisc_ops.write_wakeup()` method in order to resume 280 281 * transmission when it can accept more data to transmit. 281 282 * 282 - * TTY_LDISC_OPEN 283 + * @TTY_LDISC_OPEN: 283 284 * Indicates that a line discipline is open. For debugging purposes only. 284 285 * 285 - * TTY_PTY_LOCK 286 + * @TTY_PTY_LOCK: 286 287 * A flag private to pty code to implement %TIOCSPTLCK/%TIOCGPTLCK logic. 287 288 * 288 - * TTY_NO_WRITE_SPLIT 289 + * @TTY_NO_WRITE_SPLIT: 289 290 * Prevent driver from splitting up writes into smaller chunks (preserve 290 291 * write boundaries to driver). 291 292 * 292 - * TTY_HUPPED 293 + * @TTY_HUPPED: 293 294 * The TTY was hung up. This is set post :c:member:`tty_driver.hangup()`. 294 295 * 295 - * TTY_HUPPING 296 + * @TTY_HUPPING: 296 297 * The TTY is in the process of hanging up to abort potential readers. 297 298 * 298 - * TTY_LDISC_CHANGING 299 + * @TTY_LDISC_CHANGING: 299 300 * Line discipline for this TTY is being changed. I/O should not block 300 301 * when this is set. Use tty_io_nonblock() to check. 301 302 * 302 - * TTY_LDISC_HALTED 303 + * @TTY_LDISC_HALTED: 303 304 * Line discipline for this TTY was stopped. No work should be queued to 304 305 * this ldisc. 305 306 */ 306 - #define TTY_THROTTLED 0 307 - #define TTY_IO_ERROR 1 308 - #define TTY_OTHER_CLOSED 2 309 - #define TTY_EXCLUSIVE 3 310 - #define TTY_DO_WRITE_WAKEUP 5 311 - #define TTY_LDISC_OPEN 11 312 - #define TTY_PTY_LOCK 16 313 - #define TTY_NO_WRITE_SPLIT 17 314 - #define TTY_HUPPED 18 315 - #define TTY_HUPPING 19 316 - #define TTY_LDISC_CHANGING 20 317 - #define TTY_LDISC_HALTED 22 307 + enum tty_struct_flags { 308 + TTY_THROTTLED, 309 + TTY_IO_ERROR, 310 + TTY_OTHER_CLOSED, 311 + TTY_EXCLUSIVE, 312 + TTY_DO_WRITE_WAKEUP, 313 + TTY_LDISC_OPEN, 314 + TTY_PTY_LOCK, 315 + TTY_NO_WRITE_SPLIT, 316 + TTY_HUPPED, 317 + TTY_HUPPING, 318 + TTY_LDISC_CHANGING, 319 + TTY_LDISC_HALTED, 320 + }; 318 321 319 322 static inline bool tty_io_nonblock(struct tty_struct *tty, struct file *file) 320 323 {
+97 -83
include/linux/tty_driver.h
··· 17 17 struct serial_struct; 18 18 19 19 /** 20 + * enum tty_driver_flag -- TTY Driver Flags 21 + * 22 + * These are flags passed to tty_alloc_driver(). 23 + * 24 + * @TTY_DRIVER_INSTALLED: 25 + * Whether this driver was succesfully installed. This is a tty internal 26 + * flag. Do not touch. 27 + * 28 + * @TTY_DRIVER_RESET_TERMIOS: 29 + * Requests the tty layer to reset the termios setting when the last 30 + * process has closed the device. Used for PTYs, in particular. 31 + * 32 + * @TTY_DRIVER_REAL_RAW: 33 + * Indicates that the driver will guarantee not to set any special 34 + * character handling flags if this is set for the tty: 35 + * 36 + * ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)`` 37 + * 38 + * That is, if there is no reason for the driver to 39 + * send notifications of parity and break characters up to the line 40 + * driver, it won't do so. This allows the line driver to optimize for 41 + * this case if this flag is set. (Note that there is also a promise, if 42 + * the above case is true, not to signal overruns, either.) 43 + * 44 + * @TTY_DRIVER_DYNAMIC_DEV: 45 + * The individual tty devices need to be registered with a call to 46 + * tty_register_device() when the device is found in the system and 47 + * unregistered with a call to tty_unregister_device() so the devices will 48 + * be show up properly in sysfs. If not set, all &tty_driver.num entries 49 + * will be created by the tty core in sysfs when tty_register_driver() is 50 + * called. This is to be used by drivers that have tty devices that can 51 + * appear and disappear while the main tty driver is registered with the 52 + * tty core. 53 + * 54 + * @TTY_DRIVER_DEVPTS_MEM: 55 + * Don't use the standard arrays (&tty_driver.ttys and 56 + * &tty_driver.termios), instead use dynamic memory keyed through the 57 + * devpts filesystem. This is only applicable to the PTY driver. 58 + * 59 + * @TTY_DRIVER_HARDWARE_BREAK: 60 + * Hardware handles break signals. Pass the requested timeout to the 61 + * &tty_operations.break_ctl instead of using a simple on/off interface. 62 + * 63 + * @TTY_DRIVER_DYNAMIC_ALLOC: 64 + * Do not allocate structures which are needed per line for this driver 65 + * (&tty_driver.ports) as it would waste memory. The driver will take 66 + * care. This is only applicable to the PTY driver. 67 + * 68 + * @TTY_DRIVER_UNNUMBERED_NODE: 69 + * Do not create numbered ``/dev`` nodes. For example, create 70 + * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a 71 + * driver for a single tty device is being allocated. 72 + */ 73 + enum tty_driver_flag { 74 + TTY_DRIVER_INSTALLED = BIT(0), 75 + TTY_DRIVER_RESET_TERMIOS = BIT(1), 76 + TTY_DRIVER_REAL_RAW = BIT(2), 77 + TTY_DRIVER_DYNAMIC_DEV = BIT(3), 78 + TTY_DRIVER_DEVPTS_MEM = BIT(4), 79 + TTY_DRIVER_HARDWARE_BREAK = BIT(5), 80 + TTY_DRIVER_DYNAMIC_ALLOC = BIT(6), 81 + TTY_DRIVER_UNNUMBERED_NODE = BIT(7), 82 + }; 83 + 84 + enum tty_driver_type { 85 + TTY_DRIVER_TYPE_SYSTEM, 86 + TTY_DRIVER_TYPE_CONSOLE, 87 + TTY_DRIVER_TYPE_SERIAL, 88 + TTY_DRIVER_TYPE_PTY, 89 + TTY_DRIVER_TYPE_SCC, 90 + TTY_DRIVER_TYPE_SYSCONS, 91 + }; 92 + 93 + enum tty_driver_subtype { 94 + SYSTEM_TYPE_TTY = 1, 95 + SYSTEM_TYPE_CONSOLE, 96 + SYSTEM_TYPE_SYSCONS, 97 + SYSTEM_TYPE_SYSPTMX, 98 + 99 + PTY_TYPE_MASTER = 1, 100 + PTY_TYPE_SLAVE, 101 + 102 + SERIAL_TYPE_NORMAL = 1, 103 + }; 104 + 105 + /** 20 106 * struct tty_operations -- interface between driver and tty 21 107 * 22 108 * @lookup: ``struct tty_struct *()(struct tty_driver *self, struct file *, ··· 500 414 * @major: major /dev device number (zero for autoassignment) 501 415 * @minor_start: the first minor /dev device number 502 416 * @num: number of devices allocated 503 - * @type: type of tty driver (%TTY_DRIVER_TYPE_) 504 - * @subtype: subtype of tty driver (%SYSTEM_TYPE_, %PTY_TYPE_, %SERIAL_TYPE_) 417 + * @type: type of tty driver (enum tty_driver_type) 418 + * @subtype: subtype of tty driver (enum tty_driver_subtype) 505 419 * @init_termios: termios to set to each tty initially (e.g. %tty_std_termios) 506 420 * @flags: tty driver flags (%TTY_DRIVER_) 507 421 * @proc_entry: proc fs entry, used internally ··· 533 447 int major; 534 448 int minor_start; 535 449 unsigned int num; 536 - short type; 537 - short subtype; 450 + enum tty_driver_type type; 451 + enum tty_driver_subtype subtype; 538 452 struct ktermios init_termios; 539 453 unsigned long flags; 540 454 struct proc_dir_entry *proc_entry; ··· 564 478 565 479 void tty_driver_kref_put(struct tty_driver *driver); 566 480 567 - /* Use TTY_DRIVER_* flags below */ 481 + /** 482 + * tty_alloc_driver - allocate tty driver 483 + * @lines: count of lines this driver can handle at most 484 + * @flags: some of enum tty_driver_flag, will be set in driver->flags 485 + * 486 + * Returns: struct tty_driver or a PTR-encoded error (use IS_ERR() and friends). 487 + */ 568 488 #define tty_alloc_driver(lines, flags) \ 569 489 __tty_alloc_driver(lines, THIS_MODULE, flags) 570 490 ··· 585 493 { 586 494 driver->ops = op; 587 495 } 588 - 589 - /** 590 - * DOC: TTY Driver Flags 591 - * 592 - * TTY_DRIVER_RESET_TERMIOS 593 - * Requests the tty layer to reset the termios setting when the last 594 - * process has closed the device. Used for PTYs, in particular. 595 - * 596 - * TTY_DRIVER_REAL_RAW 597 - * Indicates that the driver will guarantee not to set any special 598 - * character handling flags if this is set for the tty: 599 - * 600 - * ``(IGNBRK || (!BRKINT && !PARMRK)) && (IGNPAR || !INPCK)`` 601 - * 602 - * That is, if there is no reason for the driver to 603 - * send notifications of parity and break characters up to the line 604 - * driver, it won't do so. This allows the line driver to optimize for 605 - * this case if this flag is set. (Note that there is also a promise, if 606 - * the above case is true, not to signal overruns, either.) 607 - * 608 - * TTY_DRIVER_DYNAMIC_DEV 609 - * The individual tty devices need to be registered with a call to 610 - * tty_register_device() when the device is found in the system and 611 - * unregistered with a call to tty_unregister_device() so the devices will 612 - * be show up properly in sysfs. If not set, all &tty_driver.num entries 613 - * will be created by the tty core in sysfs when tty_register_driver() is 614 - * called. This is to be used by drivers that have tty devices that can 615 - * appear and disappear while the main tty driver is registered with the 616 - * tty core. 617 - * 618 - * TTY_DRIVER_DEVPTS_MEM 619 - * Don't use the standard arrays (&tty_driver.ttys and 620 - * &tty_driver.termios), instead use dynamic memory keyed through the 621 - * devpts filesystem. This is only applicable to the PTY driver. 622 - * 623 - * TTY_DRIVER_HARDWARE_BREAK 624 - * Hardware handles break signals. Pass the requested timeout to the 625 - * &tty_operations.break_ctl instead of using a simple on/off interface. 626 - * 627 - * TTY_DRIVER_DYNAMIC_ALLOC 628 - * Do not allocate structures which are needed per line for this driver 629 - * (&tty_driver.ports) as it would waste memory. The driver will take 630 - * care. This is only applicable to the PTY driver. 631 - * 632 - * TTY_DRIVER_UNNUMBERED_NODE 633 - * Do not create numbered ``/dev`` nodes. For example, create 634 - * ``/dev/ttyprintk`` and not ``/dev/ttyprintk0``. Applicable only when a 635 - * driver for a single tty device is being allocated. 636 - */ 637 - #define TTY_DRIVER_INSTALLED 0x0001 638 - #define TTY_DRIVER_RESET_TERMIOS 0x0002 639 - #define TTY_DRIVER_REAL_RAW 0x0004 640 - #define TTY_DRIVER_DYNAMIC_DEV 0x0008 641 - #define TTY_DRIVER_DEVPTS_MEM 0x0010 642 - #define TTY_DRIVER_HARDWARE_BREAK 0x0020 643 - #define TTY_DRIVER_DYNAMIC_ALLOC 0x0040 644 - #define TTY_DRIVER_UNNUMBERED_NODE 0x0080 645 - 646 - /* tty driver types */ 647 - #define TTY_DRIVER_TYPE_SYSTEM 0x0001 648 - #define TTY_DRIVER_TYPE_CONSOLE 0x0002 649 - #define TTY_DRIVER_TYPE_SERIAL 0x0003 650 - #define TTY_DRIVER_TYPE_PTY 0x0004 651 - #define TTY_DRIVER_TYPE_SCC 0x0005 /* scc driver */ 652 - #define TTY_DRIVER_TYPE_SYSCONS 0x0006 653 - 654 - /* system subtypes (magic, used by tty_io.c) */ 655 - #define SYSTEM_TYPE_TTY 0x0001 656 - #define SYSTEM_TYPE_CONSOLE 0x0002 657 - #define SYSTEM_TYPE_SYSCONS 0x0003 658 - #define SYSTEM_TYPE_SYSPTMX 0x0004 659 - 660 - /* pty subtypes (magic, used by tty_io.c) */ 661 - #define PTY_TYPE_MASTER 0x0001 662 - #define PTY_TYPE_SLAVE 0x0002 663 - 664 - /* serial subtype definitions */ 665 - #define SERIAL_TYPE_NORMAL 1 666 496 667 497 int tty_register_driver(struct tty_driver *driver); 668 498 void tty_unregister_driver(struct tty_driver *driver);
-1
include/linux/tty_ldisc.h
··· 39 39 int ldsem_down_read(struct ld_semaphore *sem, long timeout); 40 40 int ldsem_down_read_trylock(struct ld_semaphore *sem); 41 41 int ldsem_down_write(struct ld_semaphore *sem, long timeout); 42 - int ldsem_down_write_trylock(struct ld_semaphore *sem); 43 42 void ldsem_up_read(struct ld_semaphore *sem); 44 43 void ldsem_up_write(struct ld_semaphore *sem); 45 44
+3 -11
kernel/debug/debug_core.c
··· 837 837 { 838 838 struct kgdb_state kgdb_var; 839 839 struct kgdb_state *ks = &kgdb_var; 840 - int ret = 0; 841 - 842 - if (arch_kgdb_ops.enable_nmi) 843 - arch_kgdb_ops.enable_nmi(0); 844 840 /* 845 841 * Avoid entering the debugger if we were triggered due to an oops 846 842 * but panic_timeout indicates the system should automatically ··· 854 858 ks->linux_regs = regs; 855 859 856 860 if (kgdb_reenter_check(ks)) 857 - goto out; /* Ouch, double exception ! */ 861 + return 0; /* Ouch, double exception ! */ 858 862 if (kgdb_info[ks->cpu].enter_kgdb != 0) 859 - goto out; 863 + return 0; 860 864 861 - ret = kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER); 862 - out: 863 - if (arch_kgdb_ops.enable_nmi) 864 - arch_kgdb_ops.enable_nmi(1); 865 - return ret; 865 + return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER); 866 866 } 867 867 NOKPROBE_SYMBOL(kgdb_handle_exception); 868 868
-37
kernel/debug/kdb/kdb_main.c
··· 25 25 #include <linux/smp.h> 26 26 #include <linux/utsname.h> 27 27 #include <linux/vmalloc.h> 28 - #include <linux/atomic.h> 29 28 #include <linux/moduleparam.h> 30 29 #include <linux/mm.h> 31 30 #include <linux/init.h> ··· 2086 2087 return 0; 2087 2088 } 2088 2089 #endif /* CONFIG_PRINTK */ 2089 - 2090 - /* Make sure we balance enable/disable calls, must disable first. */ 2091 - static atomic_t kdb_nmi_disabled; 2092 - 2093 - static int kdb_disable_nmi(int argc, const char *argv[]) 2094 - { 2095 - if (atomic_read(&kdb_nmi_disabled)) 2096 - return 0; 2097 - atomic_set(&kdb_nmi_disabled, 1); 2098 - arch_kgdb_ops.enable_nmi(0); 2099 - return 0; 2100 - } 2101 - 2102 - static int kdb_param_enable_nmi(const char *val, const struct kernel_param *kp) 2103 - { 2104 - if (!atomic_add_unless(&kdb_nmi_disabled, -1, 0)) 2105 - return -EINVAL; 2106 - arch_kgdb_ops.enable_nmi(1); 2107 - return 0; 2108 - } 2109 - 2110 - static const struct kernel_param_ops kdb_param_ops_enable_nmi = { 2111 - .set = kdb_param_enable_nmi, 2112 - }; 2113 - module_param_cb(enable_nmi, &kdb_param_ops_enable_nmi, NULL, 0600); 2114 - 2115 2090 /* 2116 2091 * kdb_cpu - This function implements the 'cpu' command. 2117 2092 * cpu [<cpunum>] ··· 2777 2804 }, 2778 2805 }; 2779 2806 2780 - static kdbtab_t nmicmd = { 2781 - .name = "disable_nmi", 2782 - .func = kdb_disable_nmi, 2783 - .usage = "", 2784 - .help = "Disable NMI entry to KDB", 2785 - .flags = KDB_ENABLE_ALWAYS_SAFE, 2786 - }; 2787 - 2788 2807 /* Initialize the kdb command table. */ 2789 2808 static void __init kdb_inittab(void) 2790 2809 { 2791 2810 kdb_register_table(maintab, ARRAY_SIZE(maintab)); 2792 - if (arch_kgdb_ops.enable_nmi) 2793 - kdb_register_table(&nmicmd, 1); 2794 2811 } 2795 2812 2796 2813 /* Execute any commands defined in kdb_cmds. */