Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (36 commits)
jsm: fixing error if the driver fails to load
jsm: removing the uart structure and filename on error
tty: Add a new VT mode which is like VT_PROCESS but doesn't require a VT_RELDISP ioctl call
tty: Keep the default buffering to sub-page units
tty: Fix up char drivers request_room usage
tty: Fix the ldisc hangup race
serial: timberdale: Remove dependancies
nozomi: Tidy up the PCI table
nozomi: Fix mutex handling
nozomi: Add tty_port usage
sdio_uart: Use kfifo instead of the messy circ stuff
serial: bcm63xx_uart: allow more than one uart to be registered.
serial: bcm63xx_uart: don't use kfree() on non kmalloced area.
serial: bfin_5xx: pull in linux/io.h for ioremap prototypes
serial: bfin_5xx: kgdboc should accept gdb break only when it is active
serial: bfin_5xx: need to disable DMA TX interrupt too
serial: bfin_5xx: remove useless gpio handling with hard flow control
Char: synclink, remove unnecessary checks
tty: declare MODULE_FIRMWARE in various drivers
ip2: Add module parameter.
...

+984 -658
+2 -14
drivers/char/cyclades.c
··· 158 158 159 159 #define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) 160 160 161 - #ifdef MODULE 162 161 static long maddr[NR_CARDS]; 163 162 static int irq[NR_CARDS]; 164 163 165 164 module_param_array(maddr, long, NULL, 0); 166 165 module_param_array(irq, int, NULL, 0); 167 - #endif 168 166 169 167 #endif /* CONFIG_ISA */ 170 168 ··· 596 598 save_car = readb(base_addr + (CyCAR << index)); 597 599 cy_writeb(base_addr + (CyCAR << index), save_xir); 598 600 599 - /* validate the port# (as configured and open) */ 600 - if (channel + chip * 4 >= cinfo->nports) { 601 - cy_writeb(base_addr + (CySRER << index), 602 - readb(base_addr + (CySRER << index)) & ~CyTxRdy); 603 - goto end; 604 - } 605 601 info = &cinfo->ports[channel + chip * 4]; 606 602 tty = tty_port_tty_get(&info->port); 607 603 if (tty == NULL) { ··· 3308 3316 unsigned short cy_isa_irq, nboard; 3309 3317 void __iomem *cy_isa_address; 3310 3318 unsigned short i, j, cy_isa_nchan; 3311 - #ifdef MODULE 3312 3319 int isparam = 0; 3313 - #endif 3314 3320 3315 3321 nboard = 0; 3316 3322 3317 - #ifdef MODULE 3318 3323 /* Check for module parameters */ 3319 3324 for (i = 0; i < NR_CARDS; i++) { 3320 3325 if (maddr[i] || i) { ··· 3321 3332 if (!maddr[i]) 3322 3333 break; 3323 3334 } 3324 - #endif 3325 3335 3326 3336 /* scan the address table probing for Cyclom-Y/ISA boards */ 3327 3337 for (i = 0; i < NR_ISA_ADDRS; i++) { ··· 3341 3353 iounmap(cy_isa_address); 3342 3354 continue; 3343 3355 } 3344 - #ifdef MODULE 3356 + 3345 3357 if (isparam && i < NR_CARDS && irq[i]) 3346 3358 cy_isa_irq = irq[i]; 3347 3359 else 3348 - #endif 3349 3360 /* find out the board's irq by probing */ 3350 3361 cy_isa_irq = detect_isa_irq(cy_isa_address); 3351 3362 if (cy_isa_irq == 0) { ··· 4195 4208 MODULE_LICENSE("GPL"); 4196 4209 MODULE_VERSION(CY_VERSION); 4197 4210 MODULE_ALIAS_CHARDEV_MAJOR(CYCLADES_MAJOR); 4211 + MODULE_FIRMWARE("cyzfirm.bin");
+1 -1
drivers/char/hvc_console.c
··· 146 146 return; 147 147 148 148 /* This console adapter was removed so it is not usable. */ 149 - if (vtermnos[index] < 0) 149 + if (vtermnos[index] == -1) 150 150 return; 151 151 152 152 while (count > 0 || i > 0) {
+20 -6
drivers/char/ip2/ip2main.c
··· 208 208 209 209 static void ip2_init_board(int, const struct firmware *); 210 210 static unsigned short find_eisa_board(int); 211 + static int ip2_setup(char *str); 211 212 212 213 /***************/ 213 214 /* Static Data */ ··· 264 263 /* Macros */ 265 264 /**********/ 266 265 267 - #if defined(MODULE) && defined(IP2DEBUG_OPEN) 266 + #ifdef IP2DEBUG_OPEN 268 267 #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] ttyc=%d, modc=%x -> %s\n", \ 269 268 tty->name,(pCh->flags), \ 270 269 tty->count,/*GET_USE_COUNT(module)*/0,s) ··· 286 285 MODULE_DESCRIPTION("Computone IntelliPort Plus Driver"); 287 286 MODULE_LICENSE("GPL"); 288 287 288 + #define MAX_CMD_STR 50 289 + 289 290 static int poll_only; 291 + static char cmd[MAX_CMD_STR]; 290 292 291 293 static int Eisa_irq; 292 294 static int Eisa_slot; ··· 313 309 MODULE_PARM_DESC(io, "I/O ports for IntelliPort Cards"); 314 310 module_param(poll_only, bool, 0); 315 311 MODULE_PARM_DESC(poll_only, "Do not use card interrupts"); 312 + module_param_string(ip2, cmd, MAX_CMD_STR, 0); 313 + MODULE_PARM_DESC(ip2, "Contains module parameter passed with 'ip2='"); 316 314 317 315 /* for sysfs class support */ 318 316 static struct class *ip2_class; ··· 493 487 return fw; 494 488 } 495 489 496 - #ifndef MODULE 497 490 /****************************************************************************** 498 491 * ip2_setup: 499 492 * str: kernel command line string ··· 536 531 return 1; 537 532 } 538 533 __setup("ip2=", ip2_setup); 539 - #endif /* !MODULE */ 540 534 541 535 static int __init ip2_loadmain(void) 542 536 { ··· 543 539 int err = 0; 544 540 i2eBordStrPtr pB = NULL; 545 541 int rc = -1; 546 - struct pci_dev *pdev = NULL; 547 542 const struct firmware *fw = NULL; 543 + char *str; 544 + 545 + str = cmd; 548 546 549 547 if (poll_only) { 550 548 /* Hard lock the interrupts to zero */ 551 549 irq[0] = irq[1] = irq[2] = irq[3] = poll_only = 0; 552 550 } 551 + 552 + /* Check module parameter with 'ip2=' has been passed or not */ 553 + if (!poll_only && (!strncmp(str, "ip2=", 4))) 554 + ip2_setup(str); 553 555 554 556 ip2trace(ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0); 555 557 ··· 622 612 case PCI: 623 613 #ifdef CONFIG_PCI 624 614 { 615 + struct pci_dev *pdev = NULL; 625 616 u32 addr; 626 617 int status; 627 618 ··· 637 626 638 627 if (pci_enable_device(pdev)) { 639 628 dev_err(&pdev->dev, "can't enable device\n"); 640 - break; 629 + goto out; 641 630 } 642 631 ip2config.type[i] = PCI; 643 632 ip2config.pci_dev[i] = pci_dev_get(pdev); ··· 649 638 dev_err(&pdev->dev, "I/O address error\n"); 650 639 651 640 ip2config.irq[i] = pdev->irq; 641 + out: 642 + pci_dev_put(pdev); 652 643 } 653 644 #else 654 645 printk(KERN_ERR "IP2: PCI card specified but PCI " ··· 669 656 break; 670 657 } /* switch */ 671 658 } /* for */ 672 - pci_dev_put(pdev); 673 659 674 660 for (i = 0; i < IP2_MAX_BOARDS; ++i) { 675 661 if (ip2config.addr[i]) { ··· 3209 3197 }; 3210 3198 3211 3199 MODULE_DEVICE_TABLE(pci, ip2main_pci_tbl); 3200 + 3201 + MODULE_FIRMWARE("intelliport2.bin");
+31 -23
drivers/char/isicom.c
··· 113 113 * 64-bit verification 114 114 */ 115 115 116 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 117 + 116 118 #include <linux/module.h> 117 119 #include <linux/firmware.h> 118 120 #include <linux/kernel.h> ··· 142 140 #define InterruptTheCard(base) outw(0, (base) + 0xc) 143 141 #define ClearInterrupt(base) inw((base) + 0x0a) 144 142 145 - #define pr_dbg(str...) pr_debug("ISICOM: " str) 146 143 #ifdef DEBUG 147 144 #define isicom_paranoia_check(a, b, c) __isicom_paranoia_check((a), (b), (c)) 148 145 #else ··· 250 249 spin_unlock_irqrestore(&card->card_lock, card->flags); 251 250 msleep(10); 252 251 } 253 - printk(KERN_WARNING "ISICOM: Failed to lock Card (0x%lx)\n", 254 - card->base); 252 + pr_warning("Failed to lock Card (0x%lx)\n", card->base); 255 253 256 254 return 0; /* Failed to acquire the card! */ 257 255 } ··· 379 379 char *name, const char *routine) 380 380 { 381 381 if (!port) { 382 - printk(KERN_WARNING "ISICOM: Warning: bad isicom magic for " 383 - "dev %s in %s.\n", name, routine); 382 + pr_warning("Warning: bad isicom magic for dev %s in %s.\n", 383 + name, routine); 384 384 return 1; 385 385 } 386 386 if (port->magic != ISICOM_MAGIC) { 387 - printk(KERN_WARNING "ISICOM: Warning: NULL isicom port for " 388 - "dev %s in %s.\n", name, routine); 387 + pr_warning("Warning: NULL isicom port for dev %s in %s.\n", 388 + name, routine); 389 389 return 1; 390 390 } 391 391 ··· 450 450 if (!(inw(base + 0x02) & (1 << port->channel))) 451 451 continue; 452 452 453 - pr_dbg("txing %d bytes, port%d.\n", txcount, 454 - port->channel + 1); 453 + pr_debug("txing %d bytes, port%d.\n", 454 + txcount, port->channel + 1); 455 455 outw((port->channel << isi_card[card].shift_count) | txcount, 456 456 base); 457 457 residue = NO; ··· 547 547 byte_count = header & 0xff; 548 548 549 549 if (channel + 1 > card->port_count) { 550 - printk(KERN_WARNING "ISICOM: isicom_interrupt(0x%lx): " 551 - "%d(channel) > port_count.\n", base, channel+1); 550 + pr_warning("%s(0x%lx): %d(channel) > port_count.\n", 551 + __func__, base, channel+1); 552 552 outw(0x0000, base+0x04); /* enable interrupts */ 553 553 spin_unlock(&card->card_lock); 554 554 return IRQ_HANDLED; ··· 582 582 if (port->status & ISI_DCD) { 583 583 if (!(header & ISI_DCD)) { 584 584 /* Carrier has been lost */ 585 - pr_dbg("interrupt: DCD->low.\n" 586 - ); 585 + pr_debug("%s: DCD->low.\n", 586 + __func__); 587 587 port->status &= ~ISI_DCD; 588 588 tty_hangup(tty); 589 589 } 590 590 } else if (header & ISI_DCD) { 591 591 /* Carrier has been detected */ 592 - pr_dbg("interrupt: DCD->high.\n"); 592 + pr_debug("%s: DCD->high.\n", 593 + __func__); 593 594 port->status |= ISI_DCD; 594 595 wake_up_interruptible(&port->port.open_wait); 595 596 } ··· 642 641 break; 643 642 644 643 case 2: /* Statistics */ 645 - pr_dbg("isicom_interrupt: stats!!!.\n"); 644 + pr_debug("%s: stats!!!\n", __func__); 646 645 break; 647 646 648 647 default: 649 - pr_dbg("Intr: Unknown code in status packet.\n"); 648 + pr_debug("%s: Unknown code in status packet.\n", 649 + __func__); 650 650 break; 651 651 } 652 652 } else { /* Data Packet */ 653 653 654 654 count = tty_prepare_flip_string(tty, &rp, byte_count & ~1); 655 - pr_dbg("Intr: Can rx %d of %d bytes.\n", count, byte_count); 655 + pr_debug("%s: Can rx %d of %d bytes.\n", 656 + __func__, count, byte_count); 656 657 word_count = count >> 1; 657 658 insw(base, rp, word_count); 658 659 byte_count -= (word_count << 1); ··· 664 661 byte_count -= 2; 665 662 } 666 663 if (byte_count > 0) { 667 - pr_dbg("Intr(0x%lx:%d): Flip buffer overflow! dropping " 668 - "bytes...\n", base, channel + 1); 664 + pr_debug("%s(0x%lx:%d): Flip buffer overflow! dropping bytes...\n", 665 + __func__, base, channel + 1); 669 666 /* drain out unread xtra data */ 670 667 while (byte_count > 0) { 671 668 inw(base); ··· 891 888 struct isi_board *card = port->card; 892 889 893 890 if (--card->count < 0) { 894 - pr_dbg("isicom_shutdown_port: bad board(0x%lx) count %d.\n", 895 - card->base, card->count); 891 + pr_debug("%s: bad board(0x%lx) count %d.\n", 892 + __func__, card->base, card->count); 896 893 card->count = 0; 897 894 } 898 895 /* last port was closed, shutdown that board too */ ··· 1684 1681 1685 1682 retval = tty_register_driver(isicom_normal); 1686 1683 if (retval) { 1687 - pr_dbg("Couldn't register the dialin driver\n"); 1684 + pr_debug("Couldn't register the dialin driver\n"); 1688 1685 goto err_puttty; 1689 1686 } 1690 1687 1691 1688 retval = pci_register_driver(&isicom_driver); 1692 1689 if (retval < 0) { 1693 - printk(KERN_ERR "ISICOM: Unable to register pci driver.\n"); 1690 + pr_err("Unable to register pci driver.\n"); 1694 1691 goto err_unrtty; 1695 1692 } 1696 1693 ··· 1720 1717 MODULE_AUTHOR("MultiTech"); 1721 1718 MODULE_DESCRIPTION("Driver for the ISI series of cards by MultiTech"); 1722 1719 MODULE_LICENSE("GPL"); 1720 + MODULE_FIRMWARE("isi608.bin"); 1721 + MODULE_FIRMWARE("isi608em.bin"); 1722 + MODULE_FIRMWARE("isi616em.bin"); 1723 + MODULE_FIRMWARE("isi4608.bin"); 1724 + MODULE_FIRMWARE("isi4616.bin");
+9 -11
drivers/char/moxa.c
··· 164 164 static unsigned int moxaLowWaterChk; 165 165 static DEFINE_MUTEX(moxa_openlock); 166 166 static DEFINE_SPINLOCK(moxa_lock); 167 - /* Variables for insmod */ 168 - #ifdef MODULE 167 + 169 168 static unsigned long baseaddr[MAX_BOARDS]; 170 169 static unsigned int type[MAX_BOARDS]; 171 170 static unsigned int numports[MAX_BOARDS]; 172 - #endif 173 171 174 172 MODULE_AUTHOR("William Chen"); 175 173 MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); 176 174 MODULE_LICENSE("GPL"); 177 - #ifdef MODULE 175 + MODULE_FIRMWARE("c218tunx.cod"); 176 + MODULE_FIRMWARE("cp204unx.cod"); 177 + MODULE_FIRMWARE("c320tunx.cod"); 178 + 178 179 module_param_array(type, uint, NULL, 0); 179 180 MODULE_PARM_DESC(type, "card type: C218=2, C320=4"); 180 181 module_param_array(baseaddr, ulong, NULL, 0); 181 182 MODULE_PARM_DESC(baseaddr, "base address"); 182 183 module_param_array(numports, uint, NULL, 0); 183 184 MODULE_PARM_DESC(numports, "numports (ignored for C218)"); 184 - #endif 185 + 185 186 module_param(ttymajor, int, 0); 186 187 187 188 /* ··· 1025 1024 { 1026 1025 unsigned int isabrds = 0; 1027 1026 int retval = 0; 1027 + struct moxa_board_conf *brd = moxa_boards; 1028 + unsigned int i; 1028 1029 1029 1030 printk(KERN_INFO "MOXA Intellio family driver version %s\n", 1030 1031 MOXA_VERSION); ··· 1054 1051 } 1055 1052 1056 1053 /* Find the boards defined from module args. */ 1057 - #ifdef MODULE 1058 - { 1059 - struct moxa_board_conf *brd = moxa_boards; 1060 - unsigned int i; 1054 + 1061 1055 for (i = 0; i < MAX_BOARDS; i++) { 1062 1056 if (!baseaddr[i]) 1063 1057 break; ··· 1087 1087 isabrds++; 1088 1088 } 1089 1089 } 1090 - } 1091 - #endif 1092 1090 1093 1091 #ifdef CONFIG_PCI 1094 1092 retval = pci_register_driver(&moxa_pci_driver);
+1 -2
drivers/char/mxser.c
··· 895 895 if (inb(info->ioaddr + UART_LSR) == 0xff) { 896 896 spin_unlock_irqrestore(&info->slock, flags); 897 897 if (capable(CAP_SYS_ADMIN)) { 898 - if (tty) 899 - set_bit(TTY_IO_ERROR, &tty->flags); 898 + set_bit(TTY_IO_ERROR, &tty->flags); 900 899 return 0; 901 900 } else 902 901 return -ENODEV;
+84 -79
drivers/char/nozomi.c
··· 136 136 #define RECEIVE_BUF_MAX 4 137 137 138 138 139 - /* Define all types of vendors and devices to support */ 140 - #define VENDOR1 0x1931 /* Vendor Option */ 141 - #define DEVICE1 0x000c /* HSDPA card */ 142 - 143 139 #define R_IIR 0x0000 /* Interrupt Identity Register */ 144 140 #define R_FCR 0x0000 /* Flow Control Register */ 145 141 #define R_IER 0x0004 /* Interrupt Enable Register */ ··· 367 371 struct mutex tty_sem; 368 372 wait_queue_head_t tty_wait; 369 373 struct async_icount tty_icount; 374 + 375 + struct nozomi *dc; 370 376 }; 371 377 372 378 /* Private data one for each card in the system */ ··· 403 405 404 406 /* Global variables */ 405 407 static const struct pci_device_id nozomi_pci_tbl[] __devinitconst = { 406 - {PCI_DEVICE(VENDOR1, DEVICE1)}, 408 + {PCI_DEVICE(0x1931, 0x000c)}, /* Nozomi HSDPA */ 407 409 {}, 408 410 }; 409 411 ··· 411 413 412 414 static struct nozomi *ndevs[NOZOMI_MAX_CARDS]; 413 415 static struct tty_driver *ntty_driver; 416 + 417 + static const struct tty_port_operations noz_tty_port_ops; 414 418 415 419 /* 416 420 * find card by tty_index ··· 852 852 ret = 1; 853 853 goto put; 854 854 } 855 - 856 - tty_buffer_request_room(tty, size); 857 855 858 856 while (size > 0) { 859 857 read_mem32((u32 *) buf, addr + offset, RECEIVE_BUF_MAX); ··· 1471 1473 1472 1474 for (i = 0; i < MAX_PORT; i++) { 1473 1475 struct device *tty_dev; 1474 - 1475 - mutex_init(&dc->port[i].tty_sem); 1476 - tty_port_init(&dc->port[i].port); 1476 + struct port *port = &dc->port[i]; 1477 + port->dc = dc; 1478 + mutex_init(&port->tty_sem); 1479 + tty_port_init(&port->port); 1480 + port->port.ops = &noz_tty_port_ops; 1477 1481 tty_dev = tty_register_device(ntty_driver, dc->index_start + i, 1478 1482 &pdev->dev); 1479 1483 ··· 1600 1600 * ---------------------------------------------------------------------------- 1601 1601 */ 1602 1602 1603 - /* Called when the userspace process opens the tty, /dev/noz*. */ 1604 - static int ntty_open(struct tty_struct *tty, struct file *file) 1603 + static int ntty_install(struct tty_driver *driver, struct tty_struct *tty) 1605 1604 { 1606 1605 struct port *port = get_port_by_tty(tty); 1607 1606 struct nozomi *dc = get_dc_by_tty(tty); 1608 - unsigned long flags; 1609 - 1607 + int ret; 1610 1608 if (!port || !dc || dc->state != NOZOMI_STATE_READY) 1611 1609 return -ENODEV; 1612 - 1613 - if (mutex_lock_interruptible(&port->tty_sem)) 1614 - return -ERESTARTSYS; 1615 - 1616 - port->port.count++; 1617 - dc->open_ttys++; 1618 - 1619 - /* Enable interrupt downlink for channel */ 1620 - if (port->port.count == 1) { 1621 - tty->driver_data = port; 1622 - tty_port_tty_set(&port->port, tty); 1623 - DBG1("open: %d", port->token_dl); 1624 - spin_lock_irqsave(&dc->spin_mutex, flags); 1625 - dc->last_ier = dc->last_ier | port->token_dl; 1626 - writew(dc->last_ier, dc->reg_ier); 1627 - spin_unlock_irqrestore(&dc->spin_mutex, flags); 1610 + ret = tty_init_termios(tty); 1611 + if (ret == 0) { 1612 + tty_driver_kref_get(driver); 1613 + driver->ttys[tty->index] = tty; 1628 1614 } 1629 - mutex_unlock(&port->tty_sem); 1615 + return ret; 1616 + } 1617 + 1618 + static void ntty_cleanup(struct tty_struct *tty) 1619 + { 1620 + tty->driver_data = NULL; 1621 + } 1622 + 1623 + static int ntty_activate(struct tty_port *tport, struct tty_struct *tty) 1624 + { 1625 + struct port *port = container_of(tport, struct port, port); 1626 + struct nozomi *dc = port->dc; 1627 + unsigned long flags; 1628 + 1629 + DBG1("open: %d", port->token_dl); 1630 + spin_lock_irqsave(&dc->spin_mutex, flags); 1631 + dc->last_ier = dc->last_ier | port->token_dl; 1632 + writew(dc->last_ier, dc->reg_ier); 1633 + dc->open_ttys++; 1634 + spin_unlock_irqrestore(&dc->spin_mutex, flags); 1635 + printk("noz: activated %d: %p\n", tty->index, tport); 1630 1636 return 0; 1631 1637 } 1632 1638 1633 - /* Called when the userspace process close the tty, /dev/noz*. Also 1634 - called immediately if ntty_open fails in which case tty->driver_data 1635 - will be NULL an we exit by the first return */ 1636 - 1637 - static void ntty_close(struct tty_struct *tty, struct file *file) 1639 + static int ntty_open(struct tty_struct *tty, struct file *filp) 1638 1640 { 1639 - struct nozomi *dc = get_dc_by_tty(tty); 1640 - struct port *nport = tty->driver_data; 1641 - struct tty_port *port = &nport->port; 1641 + struct port *port = get_port_by_tty(tty); 1642 + return tty_port_open(&port->port, tty, filp); 1643 + } 1644 + 1645 + static void ntty_shutdown(struct tty_port *tport) 1646 + { 1647 + struct port *port = container_of(tport, struct port, port); 1648 + struct nozomi *dc = port->dc; 1642 1649 unsigned long flags; 1643 1650 1644 - if (!dc || !nport) 1645 - return; 1646 - 1647 - /* Users cannot interrupt a close */ 1648 - mutex_lock(&nport->tty_sem); 1649 - 1650 - WARN_ON(!port->count); 1651 - 1651 + DBG1("close: %d", port->token_dl); 1652 + spin_lock_irqsave(&dc->spin_mutex, flags); 1653 + dc->last_ier &= ~(port->token_dl); 1654 + writew(dc->last_ier, dc->reg_ier); 1652 1655 dc->open_ttys--; 1653 - port->count--; 1656 + spin_unlock_irqrestore(&dc->spin_mutex, flags); 1657 + printk("noz: shutdown %p\n", tport); 1658 + } 1654 1659 1655 - if (port->count == 0) { 1656 - DBG1("close: %d", nport->token_dl); 1657 - tty_port_tty_set(port, NULL); 1658 - spin_lock_irqsave(&dc->spin_mutex, flags); 1659 - dc->last_ier &= ~(nport->token_dl); 1660 - writew(dc->last_ier, dc->reg_ier); 1661 - spin_unlock_irqrestore(&dc->spin_mutex, flags); 1662 - } 1663 - mutex_unlock(&nport->tty_sem); 1660 + static void ntty_close(struct tty_struct *tty, struct file *filp) 1661 + { 1662 + struct port *port = tty->driver_data; 1663 + if (port) 1664 + tty_port_close(&port->port, tty, filp); 1665 + } 1666 + 1667 + static void ntty_hangup(struct tty_struct *tty) 1668 + { 1669 + struct port *port = tty->driver_data; 1670 + tty_port_hangup(&port->port); 1664 1671 } 1665 1672 1666 1673 /* ··· 1687 1680 if (!dc || !port) 1688 1681 return -ENODEV; 1689 1682 1690 - if (unlikely(!mutex_trylock(&port->tty_sem))) { 1691 - /* 1692 - * must test lock as tty layer wraps calls 1693 - * to this function with BKL 1694 - */ 1695 - dev_err(&dc->pdev->dev, "Would have deadlocked - " 1696 - "return EAGAIN\n"); 1697 - return -EAGAIN; 1698 - } 1683 + mutex_lock(&port->tty_sem); 1699 1684 1700 1685 if (unlikely(!port->port.count)) { 1701 1686 DBG1(" "); ··· 1727 1728 * This method is called by the upper tty layer. 1728 1729 * #according to sources N_TTY.c it expects a value >= 0 and 1729 1730 * does not check for negative values. 1731 + * 1732 + * If the port is unplugged report lots of room and let the bits 1733 + * dribble away so we don't block anything. 1730 1734 */ 1731 1735 static int ntty_write_room(struct tty_struct *tty) 1732 1736 { 1733 1737 struct port *port = tty->driver_data; 1734 - int room = 0; 1738 + int room = 4096; 1735 1739 const struct nozomi *dc = get_dc_by_tty(tty); 1736 1740 1737 - if (!dc || !port) 1738 - return 0; 1739 - if (!mutex_trylock(&port->tty_sem)) 1740 - return 0; 1741 - 1742 - if (!port->port.count) 1743 - goto exit; 1744 - 1745 - room = port->fifo_ul.size - kfifo_len(&port->fifo_ul); 1746 - 1747 - exit: 1748 - mutex_unlock(&port->tty_sem); 1741 + if (dc) { 1742 + mutex_lock(&port->tty_sem); 1743 + if (port->port.count) 1744 + room = port->fifo_ul.size - 1745 + kfifo_len(&port->fifo_ul); 1746 + mutex_unlock(&port->tty_sem); 1747 + } 1749 1748 return room; 1750 1749 } 1751 1750 ··· 1903 1906 return rval; 1904 1907 } 1905 1908 1909 + static const struct tty_port_operations noz_tty_port_ops = { 1910 + .activate = ntty_activate, 1911 + .shutdown = ntty_shutdown, 1912 + }; 1913 + 1906 1914 static const struct tty_operations tty_ops = { 1907 1915 .ioctl = ntty_ioctl, 1908 1916 .open = ntty_open, 1909 1917 .close = ntty_close, 1918 + .hangup = ntty_hangup, 1910 1919 .write = ntty_write, 1911 1920 .write_room = ntty_write_room, 1912 1921 .unthrottle = ntty_unthrottle, ··· 1920 1917 .chars_in_buffer = ntty_chars_in_buffer, 1921 1918 .tiocmget = ntty_tiocmget, 1922 1919 .tiocmset = ntty_tiocmset, 1920 + .install = ntty_install, 1921 + .cleanup = ntty_cleanup, 1923 1922 }; 1924 1923 1925 1924 /* Module initialization */
+1 -2
drivers/char/serial167.c
··· 658 658 info->mon.char_max = char_count; 659 659 info->mon.char_last = char_count; 660 660 #endif 661 - len = tty_buffer_request_room(tty, char_count); 662 - while (len--) { 661 + while (char_count--) { 663 662 data = base_addr[CyRDR]; 664 663 tty_insert_flip_char(tty, data, TTY_NORMAL); 665 664 #ifdef CYCLOM_16Y_HACK
-2
drivers/char/specialix.c
··· 646 646 dprintk(SX_DEBUG_RX, "port: %p: count: %d\n", port, count); 647 647 port->hits[count > 8 ? 9 : count]++; 648 648 649 - tty_buffer_request_room(tty, count); 650 - 651 649 while (count--) 652 650 tty_insert_flip_char(tty, sx_in(bp, CD186x_RDR), TTY_NORMAL); 653 651 tty_flip_buffer_push(tty);
+2 -2
drivers/char/synclink.c
··· 2031 2031 if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) 2032 2032 return 0; 2033 2033 2034 - if (!tty || !info->xmit_buf) 2034 + if (!info->xmit_buf) 2035 2035 return 0; 2036 2036 2037 2037 spin_lock_irqsave(&info->irq_spinlock, flags); ··· 2121 2121 if (mgsl_paranoia_check(info, tty->name, "mgsl_write")) 2122 2122 goto cleanup; 2123 2123 2124 - if (!tty || !info->xmit_buf) 2124 + if (!info->xmit_buf) 2125 2125 goto cleanup; 2126 2126 2127 2127 if ( info->params.mode == MGSL_MODE_HDLC ||
+4 -2
drivers/char/tty_buffer.c
··· 247 247 { 248 248 int copied = 0; 249 249 do { 250 - int space = tty_buffer_request_room(tty, size - copied); 250 + int goal = min(size - copied, TTY_BUFFER_PAGE); 251 + int space = tty_buffer_request_room(tty, goal); 251 252 struct tty_buffer *tb = tty->buf.tail; 252 253 /* If there is no space then tb may be NULL */ 253 254 if (unlikely(space == 0)) ··· 284 283 { 285 284 int copied = 0; 286 285 do { 287 - int space = tty_buffer_request_room(tty, size - copied); 286 + int goal = min(size - copied, TTY_BUFFER_PAGE); 287 + int space = tty_buffer_request_room(tty, goal); 288 288 struct tty_buffer *tb = tty->buf.tail; 289 289 /* If there is no space then tb may be NULL */ 290 290 if (unlikely(space == 0))
+31 -21
drivers/char/tty_ldisc.c
··· 706 706 /** 707 707 * tty_ldisc_reinit - reinitialise the tty ldisc 708 708 * @tty: tty to reinit 709 + * @ldisc: line discipline to reinitialize 709 710 * 710 - * Switch the tty back to N_TTY line discipline and leave the 711 - * ldisc state closed 711 + * Switch the tty to a line discipline and leave the ldisc 712 + * state closed 712 713 */ 713 714 714 - static void tty_ldisc_reinit(struct tty_struct *tty) 715 + static void tty_ldisc_reinit(struct tty_struct *tty, int ldisc) 715 716 { 716 717 struct tty_ldisc *ld; 717 718 ··· 722 721 /* 723 722 * Switch the line discipline back 724 723 */ 725 - ld = tty_ldisc_get(N_TTY); 724 + ld = tty_ldisc_get(ldisc); 726 725 BUG_ON(IS_ERR(ld)); 727 726 tty_ldisc_assign(tty, ld); 728 - tty_set_termios_ldisc(tty, N_TTY); 727 + tty_set_termios_ldisc(tty, ldisc); 729 728 } 730 729 731 730 /** ··· 746 745 void tty_ldisc_hangup(struct tty_struct *tty) 747 746 { 748 747 struct tty_ldisc *ld; 748 + int reset = tty->driver->flags & TTY_DRIVER_RESET_TERMIOS; 749 + int err = 0; 749 750 750 751 /* 751 752 * FIXME! What are the locking issues here? This may me overdoing ··· 775 772 wake_up_interruptible_poll(&tty->read_wait, POLLIN); 776 773 /* 777 774 * Shutdown the current line discipline, and reset it to 778 - * N_TTY. 775 + * N_TTY if need be. 776 + * 777 + * Avoid racing set_ldisc or tty_ldisc_release 779 778 */ 780 - if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) { 781 - /* Avoid racing set_ldisc or tty_ldisc_release */ 782 - mutex_lock(&tty->ldisc_mutex); 783 - tty_ldisc_halt(tty); 784 - if (tty->ldisc) { /* Not yet closed */ 785 - /* Switch back to N_TTY */ 786 - tty_ldisc_reinit(tty); 787 - /* At this point we have a closed ldisc and we want to 788 - reopen it. We could defer this to the next open but 789 - it means auditing a lot of other paths so this is 790 - a FIXME */ 791 - WARN_ON(tty_ldisc_open(tty, tty->ldisc)); 792 - tty_ldisc_enable(tty); 779 + mutex_lock(&tty->ldisc_mutex); 780 + tty_ldisc_halt(tty); 781 + /* At this point we have a closed ldisc and we want to 782 + reopen it. We could defer this to the next open but 783 + it means auditing a lot of other paths so this is 784 + a FIXME */ 785 + if (tty->ldisc) { /* Not yet closed */ 786 + if (reset == 0) { 787 + tty_ldisc_reinit(tty, tty->termios->c_line); 788 + err = tty_ldisc_open(tty, tty->ldisc); 793 789 } 794 - mutex_unlock(&tty->ldisc_mutex); 795 - tty_reset_termios(tty); 790 + /* If the re-open fails or we reset then go to N_TTY. The 791 + N_TTY open cannot fail */ 792 + if (reset || err) { 793 + tty_ldisc_reinit(tty, N_TTY); 794 + WARN_ON(tty_ldisc_open(tty, tty->ldisc)); 795 + } 796 + tty_ldisc_enable(tty); 796 797 } 798 + mutex_unlock(&tty->ldisc_mutex); 799 + if (reset) 800 + tty_reset_termios(tty); 797 801 } 798 802 799 803 /**
+20 -19
drivers/char/vt_ioctl.c
··· 888 888 ret = -EFAULT; 889 889 goto out; 890 890 } 891 - if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) { 891 + if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS && tmp.mode != VT_PROCESS_AUTO) { 892 892 ret = -EINVAL; 893 893 goto out; 894 894 } ··· 1622 1622 * telling it that it has acquired. Also check if it has died and 1623 1623 * clean up (similar to logic employed in change_console()) 1624 1624 */ 1625 - if (vc->vt_mode.mode == VT_PROCESS) { 1625 + if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { 1626 1626 /* 1627 1627 * Send the signal as privileged - kill_pid() will 1628 1628 * tell us if the process has gone or something else ··· 1682 1682 * vt to auto control. 1683 1683 */ 1684 1684 vc = vc_cons[fg_console].d; 1685 - if (vc->vt_mode.mode == VT_PROCESS) { 1685 + if (vc->vt_mode.mode == VT_PROCESS || vc->vt_mode.mode == VT_PROCESS_AUTO) { 1686 1686 /* 1687 1687 * Send the signal as privileged - kill_pid() will 1688 1688 * tell us if the process has gone or something else ··· 1693 1693 */ 1694 1694 vc->vt_newvt = new_vc->vc_num; 1695 1695 if (kill_pid(vc->vt_pid, vc->vt_mode.relsig, 1) == 0) { 1696 + if(vc->vt_mode.mode == VT_PROCESS) 1697 + /* 1698 + * It worked. Mark the vt to switch to and 1699 + * return. The process needs to send us a 1700 + * VT_RELDISP ioctl to complete the switch. 1701 + */ 1702 + return; 1703 + } else { 1696 1704 /* 1697 - * It worked. Mark the vt to switch to and 1698 - * return. The process needs to send us a 1699 - * VT_RELDISP ioctl to complete the switch. 1705 + * The controlling process has died, so we revert back to 1706 + * normal operation. In this case, we'll also change back 1707 + * to KD_TEXT mode. I'm not sure if this is strictly correct 1708 + * but it saves the agony when the X server dies and the screen 1709 + * remains blanked due to KD_GRAPHICS! It would be nice to do 1710 + * this outside of VT_PROCESS but there is no single process 1711 + * to account for and tracking tty count may be undesirable. 1700 1712 */ 1701 - return; 1713 + reset_vc(vc); 1702 1714 } 1703 1715 1704 1716 /* 1705 - * The controlling process has died, so we revert back to 1706 - * normal operation. In this case, we'll also change back 1707 - * to KD_TEXT mode. I'm not sure if this is strictly correct 1708 - * but it saves the agony when the X server dies and the screen 1709 - * remains blanked due to KD_GRAPHICS! It would be nice to do 1710 - * this outside of VT_PROCESS but there is no single process 1711 - * to account for and tracking tty count may be undesirable. 1712 - */ 1713 - reset_vc(vc); 1714 - 1715 - /* 1716 - * Fall through to normal (VT_AUTO) handling of the switch... 1717 + * Fall through to normal (VT_AUTO and VT_PROCESS_AUTO) handling of the switch... 1717 1718 */ 1718 1719 } 1719 1720
+30 -63
drivers/mmc/card/sdio_uart.c
··· 37 37 #include <linux/gfp.h> 38 38 #include <linux/tty.h> 39 39 #include <linux/tty_flip.h> 40 + #include <linux/kfifo.h> 40 41 41 42 #include <linux/mmc/core.h> 42 43 #include <linux/mmc/card.h> ··· 48 47 #define UART_NR 8 /* Number of UARTs this driver can handle */ 49 48 50 49 51 - #define UART_XMIT_SIZE PAGE_SIZE 50 + #define FIFO_SIZE PAGE_SIZE 52 51 #define WAKEUP_CHARS 256 53 - 54 - #define circ_empty(circ) ((circ)->head == (circ)->tail) 55 - #define circ_clear(circ) ((circ)->head = (circ)->tail = 0) 56 - 57 - #define circ_chars_pending(circ) \ 58 - (CIRC_CNT((circ)->head, (circ)->tail, UART_XMIT_SIZE)) 59 - 60 - #define circ_chars_free(circ) \ 61 - (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE)) 62 - 63 52 64 53 struct uart_icount { 65 54 __u32 cts; ··· 73 82 struct mutex func_lock; 74 83 struct task_struct *in_sdio_uart_irq; 75 84 unsigned int regs_offset; 76 - struct circ_buf xmit; 85 + struct kfifo xmit_fifo; 77 86 spinlock_t write_lock; 78 87 struct uart_icount icount; 79 88 unsigned int uartclk; ··· 96 105 kref_init(&port->kref); 97 106 mutex_init(&port->func_lock); 98 107 spin_lock_init(&port->write_lock); 108 + if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE, GFP_KERNEL)) 109 + return -ENOMEM; 99 110 100 111 spin_lock(&sdio_uart_table_lock); 101 112 for (index = 0; index < UART_NR; index++) { ··· 133 140 { 134 141 struct sdio_uart_port *port = 135 142 container_of(kref, struct sdio_uart_port, kref); 143 + kfifo_free(&port->xmit_fifo); 136 144 kfree(port); 137 145 } 138 146 ··· 450 456 451 457 static void sdio_uart_transmit_chars(struct sdio_uart_port *port) 452 458 { 453 - struct circ_buf *xmit = &port->xmit; 459 + struct kfifo *xmit = &port->xmit_fifo; 454 460 int count; 455 461 struct tty_struct *tty; 462 + u8 iobuf[16]; 463 + int len; 456 464 457 465 if (port->x_char) { 458 466 sdio_out(port, UART_TX, port->x_char); ··· 465 469 466 470 tty = tty_port_tty_get(&port->port); 467 471 468 - if (tty == NULL || circ_empty(xmit) || 472 + if (tty == NULL || !kfifo_len(xmit) || 469 473 tty->stopped || tty->hw_stopped) { 470 474 sdio_uart_stop_tx(port); 471 475 tty_kref_put(tty); 472 476 return; 473 477 } 474 478 475 - count = 16; 476 - do { 477 - sdio_out(port, UART_TX, xmit->buf[xmit->tail]); 478 - xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 479 + len = kfifo_out_locked(xmit, iobuf, 16, &port->write_lock); 480 + for (count = 0; count < len; count++) { 481 + sdio_out(port, UART_TX, iobuf[count]); 479 482 port->icount.tx++; 480 - if (circ_empty(xmit)) 481 - break; 482 - } while (--count > 0); 483 + } 483 484 484 - if (circ_chars_pending(xmit) < WAKEUP_CHARS) 485 + len = kfifo_len(xmit); 486 + if (len < WAKEUP_CHARS) { 485 487 tty_wakeup(tty); 486 - 487 - if (circ_empty(xmit)) 488 - sdio_uart_stop_tx(port); 488 + if (len == 0) 489 + sdio_uart_stop_tx(port); 490 + } 489 491 tty_kref_put(tty); 490 492 } 491 493 ··· 626 632 { 627 633 struct sdio_uart_port *port = 628 634 container_of(tport, struct sdio_uart_port, port); 629 - unsigned long page; 630 635 int ret; 631 636 632 637 /* ··· 634 641 */ 635 642 set_bit(TTY_IO_ERROR, &tty->flags); 636 643 637 - /* Initialise and allocate the transmit buffer. */ 638 - page = __get_free_page(GFP_KERNEL); 639 - if (!page) 640 - return -ENOMEM; 641 - port->xmit.buf = (unsigned char *)page; 642 - circ_clear(&port->xmit); 644 + kfifo_reset(&port->xmit_fifo); 643 645 644 646 ret = sdio_uart_claim_func(port); 645 647 if (ret) 646 - goto err1; 648 + return ret; 647 649 ret = sdio_enable_func(port->func); 648 650 if (ret) 649 - goto err2; 651 + goto err1; 650 652 ret = sdio_claim_irq(port->func, sdio_uart_irq); 651 653 if (ret) 652 - goto err3; 654 + goto err2; 653 655 654 656 /* 655 657 * Clear the FIFO buffers and disable them. ··· 688 700 sdio_uart_release_func(port); 689 701 return 0; 690 702 691 - err3: 692 - sdio_disable_func(port->func); 693 703 err2: 694 - sdio_uart_release_func(port); 704 + sdio_disable_func(port->func); 695 705 err1: 696 - free_page((unsigned long)port->xmit.buf); 706 + sdio_uart_release_func(port); 697 707 return ret; 698 708 } 699 709 ··· 713 727 714 728 ret = sdio_uart_claim_func(port); 715 729 if (ret) 716 - goto skip; 730 + return; 717 731 718 732 sdio_uart_stop_rx(port); 719 733 ··· 735 749 sdio_disable_func(port->func); 736 750 737 751 sdio_uart_release_func(port); 738 - 739 - skip: 740 - /* Free the transmit buffer page. */ 741 - free_page((unsigned long)port->xmit.buf); 742 752 } 743 753 744 754 /** ··· 804 822 int count) 805 823 { 806 824 struct sdio_uart_port *port = tty->driver_data; 807 - struct circ_buf *circ = &port->xmit; 808 - int c, ret = 0; 825 + int ret; 809 826 810 827 if (!port->func) 811 828 return -ENODEV; 812 829 813 - spin_lock(&port->write_lock); 814 - while (1) { 815 - c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE); 816 - if (count < c) 817 - c = count; 818 - if (c <= 0) 819 - break; 820 - memcpy(circ->buf + circ->head, buf, c); 821 - circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1); 822 - buf += c; 823 - count -= c; 824 - ret += c; 825 - } 826 - spin_unlock(&port->write_lock); 827 - 830 + ret = kfifo_in_locked(&port->xmit_fifo, buf, count, &port->write_lock); 828 831 if (!(port->ier & UART_IER_THRI)) { 829 832 int err = sdio_uart_claim_func(port); 830 833 if (!err) { ··· 826 859 static int sdio_uart_write_room(struct tty_struct *tty) 827 860 { 828 861 struct sdio_uart_port *port = tty->driver_data; 829 - return port ? circ_chars_free(&port->xmit) : 0; 862 + return FIFO_SIZE - kfifo_len(&port->xmit_fifo); 830 863 } 831 864 832 865 static int sdio_uart_chars_in_buffer(struct tty_struct *tty) 833 866 { 834 867 struct sdio_uart_port *port = tty->driver_data; 835 - return port ? circ_chars_pending(&port->xmit) : 0; 868 + return kfifo_len(&port->xmit_fifo); 836 869 } 837 870 838 871 static void sdio_uart_send_xchar(struct tty_struct *tty, char ch)
+6
drivers/parport/parport_pc.c
··· 2908 2908 netmos_9805, 2909 2909 netmos_9815, 2910 2910 netmos_9901, 2911 + netmos_9865, 2911 2912 quatech_sppxp100, 2912 2913 }; 2913 2914 ··· 2990 2989 /* netmos_9805 */ { 1, { { 0, -1 }, } }, 2991 2990 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, 2992 2991 /* netmos_9901 */ { 1, { { 0, -1 }, } }, 2992 + /* netmos_9865 */ { 1, { { 0, -1 }, } }, 2993 2993 /* quatech_sppxp100 */ { 1, { { 0, 1 }, } }, 2994 2994 }; 2995 2995 ··· 3094 3092 PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9815 }, 3095 3093 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9901, 3096 3094 0xA000, 0x2000, 0, 0, netmos_9901 }, 3095 + { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865, 3096 + 0xA000, 0x1000, 0, 0, netmos_9865 }, 3097 + { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865, 3098 + 0xA000, 0x2000, 0, 0, netmos_9865 }, 3097 3099 /* Quatech SPPXP-100 Parallel port PCI ExpressCard */ 3098 3100 { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SPPXP_100, 3099 3101 PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 },
+3 -5
drivers/serial/68328serial.c
··· 153 153 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 154 154 9600, 19200, 38400, 57600, 115200, 0 }; 155 155 156 - #define BAUD_TABLE_SIZE (sizeof(baud_table)/sizeof(baud_table[0])) 157 - 158 156 /* Sets or clears DTR/RTS on the requested line */ 159 157 static inline void m68k_rtsdtr(struct m68k_serial *ss, int set) 160 158 { ··· 1404 1406 USTCNT = ustcnt & ~USTCNT_TXEN; 1405 1407 1406 1408 again: 1407 - for (i = 0; i < sizeof(baud_table) / sizeof(baud_table[0]); i++) 1409 + for (i = 0; i < ARRAY_SIZE(baud_table); i++) 1408 1410 if (baud_table[i] == m68328_console_baud) 1409 1411 break; 1410 - if (i >= sizeof(baud_table) / sizeof(baud_table[0])) { 1412 + if (i >= ARRAY_SIZE(baud_table)) { 1411 1413 m68328_console_baud = 9600; 1412 1414 goto again; 1413 1415 } ··· 1433 1435 if (arg) 1434 1436 n = simple_strtoul(arg,NULL,0); 1435 1437 1436 - for (i = 0; i < BAUD_TABLE_SIZE; i++) 1438 + for (i = 0; i < ARRAY_SIZE(baud_table); i++) 1437 1439 if (baud_table[i] == n) 1438 1440 break; 1439 1441 if (i < BAUD_TABLE_SIZE) {
+15 -6
drivers/serial/8250.c
··· 2690 2690 } 2691 2691 } 2692 2692 2693 + static void 2694 + serial8250_init_fixed_type_port(struct uart_8250_port *up, unsigned int type) 2695 + { 2696 + up->port.type = type; 2697 + up->port.fifosize = uart_config[type].fifo_size; 2698 + up->capabilities = uart_config[type].flags; 2699 + up->tx_loadsz = uart_config[type].tx_loadsz; 2700 + } 2701 + 2693 2702 static void __init 2694 2703 serial8250_register_ports(struct uart_driver *drv, struct device *dev) 2695 2704 { ··· 2715 2706 struct uart_8250_port *up = &serial8250_ports[i]; 2716 2707 2717 2708 up->port.dev = dev; 2709 + 2710 + if (up->port.flags & UPF_FIXED_TYPE) 2711 + serial8250_init_fixed_type_port(up, up->port.type); 2712 + 2718 2713 uart_add_one_port(drv, &up->port); 2719 2714 } 2720 2715 } ··· 3131 3118 if (port->dev) 3132 3119 uart->port.dev = port->dev; 3133 3120 3134 - if (port->flags & UPF_FIXED_TYPE) { 3135 - uart->port.type = port->type; 3136 - uart->port.fifosize = uart_config[port->type].fifo_size; 3137 - uart->capabilities = uart_config[port->type].flags; 3138 - uart->tx_loadsz = uart_config[port->type].tx_loadsz; 3139 - } 3121 + if (port->flags & UPF_FIXED_TYPE) 3122 + serial8250_init_fixed_type_port(uart, port->type); 3140 3123 3141 3124 set_io_from_upio(&uart->port); 3142 3125 /* Possibly override default I/O functions. */
+30 -1
drivers/serial/8250_pci.c
··· 760 760 /* subdevice 0x00PS means <P> parallel, <S> serial */ 761 761 unsigned int num_serial = dev->subsystem_device & 0xf; 762 762 763 - if (dev->device == PCI_DEVICE_ID_NETMOS_9901) 763 + if ((dev->device == PCI_DEVICE_ID_NETMOS_9901) || 764 + (dev->device == PCI_DEVICE_ID_NETMOS_9865)) 764 765 return 0; 765 766 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM && 766 767 dev->subsystem_device == 0x0299) ··· 1480 1479 1481 1480 pbn_b0_bt_1_115200, 1482 1481 pbn_b0_bt_2_115200, 1482 + pbn_b0_bt_4_115200, 1483 1483 pbn_b0_bt_8_115200, 1484 1484 1485 1485 pbn_b0_bt_1_460800, ··· 1702 1700 [pbn_b0_bt_2_115200] = { 1703 1701 .flags = FL_BASE0|FL_BASE_BARS, 1704 1702 .num_ports = 2, 1703 + .base_baud = 115200, 1704 + .uart_offset = 8, 1705 + }, 1706 + [pbn_b0_bt_4_115200] = { 1707 + .flags = FL_BASE0|FL_BASE_BARS, 1708 + .num_ports = 4, 1705 1709 .base_baud = 115200, 1706 1710 .uart_offset = 8, 1707 1711 }, ··· 3199 3191 0x1208, 0x0004, 0, 0, 3200 3192 pbn_b0_4_921600 }, 3201 3193 3194 + { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF2, 3195 + 0x1204, 0x0004, 0, 0, 3196 + pbn_b0_4_921600 }, 3197 + { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF2, 3198 + 0x1208, 0x0004, 0, 0, 3199 + pbn_b0_4_921600 }, 3200 + { PCI_VENDOR_ID_KORENIX, PCI_DEVICE_ID_KORENIX_JETCARDF3, 3201 + 0x1208, 0x0004, 0, 0, 3202 + pbn_b0_4_921600 }, 3202 3203 /* 3203 3204 * Dell Remote Access Card 4 - Tim_T_Murphy@Dell.com 3204 3205 */ ··· 3664 3647 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9901, 3665 3648 0xA000, 0x1000, 3666 3649 0, 0, pbn_b0_1_115200 }, 3650 + 3651 + /* 3652 + * Best Connectivity PCI Multi I/O cards 3653 + */ 3654 + 3655 + { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865, 3656 + 0xA000, 0x1000, 3657 + 0, 0, pbn_b0_1_115200 }, 3658 + 3659 + { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865, 3660 + 0xA000, 0x3004, 3661 + 0, 0, pbn_b0_bt_4_115200 }, 3667 3662 3668 3663 /* 3669 3664 * These entries match devices with class COMMUNICATION_SERIAL,
+25 -30
drivers/serial/Kconfig
··· 1418 1418 To compile this driver as a module, choose M here: the 1419 1419 module will be called bfin_sport_uart. 1420 1420 1421 - choice 1422 - prompt "Baud rate for Blackfin SPORT UART" 1423 - depends on SERIAL_BFIN_SPORT 1424 - default SERIAL_SPORT_BAUD_RATE_57600 1421 + config SERIAL_BFIN_SPORT_CONSOLE 1422 + bool "Console on Blackfin sport emulated uart" 1423 + depends on SERIAL_BFIN_SPORT=y 1424 + select SERIAL_CORE_CONSOLE 1425 + 1426 + config SERIAL_BFIN_SPORT0_UART 1427 + bool "Enable UART over SPORT0" 1428 + depends on SERIAL_BFIN_SPORT && !(BF542 || BF542M || BF544 || BF544M) 1425 1429 help 1426 - Choose a baud rate for the SPORT UART, other uart settings are 1427 - 8 bit, 1 stop bit, no parity, no flow control. 1430 + Enable UART over SPORT0 1428 1431 1429 - config SERIAL_SPORT_BAUD_RATE_115200 1430 - bool "115200" 1431 - 1432 - config SERIAL_SPORT_BAUD_RATE_57600 1433 - bool "57600" 1434 - 1435 - config SERIAL_SPORT_BAUD_RATE_38400 1436 - bool "38400" 1437 - 1438 - config SERIAL_SPORT_BAUD_RATE_19200 1439 - bool "19200" 1440 - 1441 - config SERIAL_SPORT_BAUD_RATE_9600 1442 - bool "9600" 1443 - endchoice 1444 - 1445 - config SPORT_BAUD_RATE 1446 - int 1432 + config SERIAL_BFIN_SPORT1_UART 1433 + bool "Enable UART over SPORT1" 1447 1434 depends on SERIAL_BFIN_SPORT 1448 - default 115200 if (SERIAL_SPORT_BAUD_RATE_115200) 1449 - default 57600 if (SERIAL_SPORT_BAUD_RATE_57600) 1450 - default 38400 if (SERIAL_SPORT_BAUD_RATE_38400) 1451 - default 19200 if (SERIAL_SPORT_BAUD_RATE_19200) 1452 - default 9600 if (SERIAL_SPORT_BAUD_RATE_9600) 1435 + help 1436 + Enable UART over SPORT1 1437 + 1438 + config SERIAL_BFIN_SPORT2_UART 1439 + bool "Enable UART over SPORT2" 1440 + depends on SERIAL_BFIN_SPORT && (BF54x || BF538 || BF539) 1441 + help 1442 + Enable UART over SPORT2 1443 + 1444 + config SERIAL_BFIN_SPORT3_UART 1445 + bool "Enable UART over SPORT3" 1446 + depends on SERIAL_BFIN_SPORT && (BF54x || BF538 || BF539) 1447 + help 1448 + Enable UART over SPORT3 1453 1449 1454 1450 config SERIAL_TIMBERDALE 1455 1451 tristate "Support for timberdale UART" 1456 - depends on MFD_TIMBERDALE 1457 1452 select SERIAL_CORE 1458 1453 ---help--- 1459 1454 Add support for UART controller on timberdale.
+22
drivers/serial/atmel_serial.c
··· 1213 1213 return ret; 1214 1214 } 1215 1215 1216 + #ifdef CONFIG_CONSOLE_POLL 1217 + static int atmel_poll_get_char(struct uart_port *port) 1218 + { 1219 + while (!(UART_GET_CSR(port) & ATMEL_US_RXRDY)) 1220 + cpu_relax(); 1221 + 1222 + return UART_GET_CHAR(port); 1223 + } 1224 + 1225 + static void atmel_poll_put_char(struct uart_port *port, unsigned char ch) 1226 + { 1227 + while (!(UART_GET_CSR(port) & ATMEL_US_TXRDY)) 1228 + cpu_relax(); 1229 + 1230 + UART_PUT_CHAR(port, ch); 1231 + } 1232 + #endif 1233 + 1216 1234 static struct uart_ops atmel_pops = { 1217 1235 .tx_empty = atmel_tx_empty, 1218 1236 .set_mctrl = atmel_set_mctrl, ··· 1250 1232 .config_port = atmel_config_port, 1251 1233 .verify_port = atmel_verify_port, 1252 1234 .pm = atmel_serial_pm, 1235 + #ifdef CONFIG_CONSOLE_POLL 1236 + .poll_get_char = atmel_poll_get_char, 1237 + .poll_put_char = atmel_poll_put_char, 1238 + #endif 1253 1239 }; 1254 1240 1255 1241 /*
+4 -3
drivers/serial/bcm63xx_uart.c
··· 35 35 #include <bcm63xx_regs.h> 36 36 #include <bcm63xx_io.h> 37 37 38 - #define BCM63XX_NR_UARTS 1 38 + #define BCM63XX_NR_UARTS 2 39 39 40 40 static struct uart_port ports[BCM63XX_NR_UARTS]; 41 41 ··· 784 784 .dev_name = "ttyS", 785 785 .major = TTY_MAJOR, 786 786 .minor = 64, 787 - .nr = 1, 787 + .nr = BCM63XX_NR_UARTS, 788 788 .cons = BCM63XX_CONSOLE, 789 789 }; 790 790 ··· 826 826 port->dev = &pdev->dev; 827 827 port->fifosize = 16; 828 828 port->uartclk = clk_get_rate(clk) / 2; 829 + port->line = pdev->id; 829 830 clk_put(clk); 830 831 831 832 ret = uart_add_one_port(&bcm_uart_driver, port); 832 833 if (ret) { 833 - kfree(port); 834 + ports[pdev->id].membase = 0; 834 835 return ret; 835 836 } 836 837 platform_set_drvdata(pdev, port);
+6 -16
drivers/serial/bfin_5xx.c
··· 14 14 15 15 #include <linux/module.h> 16 16 #include <linux/ioport.h> 17 + #include <linux/io.h> 17 18 #include <linux/init.h> 18 19 #include <linux/console.h> 19 20 #include <linux/sysrq.h> ··· 238 237 239 238 #if defined(CONFIG_KGDB_SERIAL_CONSOLE) || \ 240 239 defined(CONFIG_KGDB_SERIAL_CONSOLE_MODULE) 241 - if (kgdb_connected && kgdboc_port_line == uart->port.line) 240 + if (kgdb_connected && kgdboc_port_line == uart->port.line 241 + && kgdboc_break_enabled) 242 242 if (ch == 0x3) {/* Ctrl + C */ 243 243 kgdb_breakpoint(); 244 244 return; ··· 490 488 { 491 489 int x_pos, pos; 492 490 491 + dma_disable_irq(uart->tx_dma_channel); 493 492 dma_disable_irq(uart->rx_dma_channel); 494 493 spin_lock_bh(&uart->port.lock); 495 494 ··· 524 521 } 525 522 526 523 spin_unlock_bh(&uart->port.lock); 524 + dma_enable_irq(uart->tx_dma_channel); 527 525 dma_enable_irq(uart->rx_dma_channel); 528 526 529 527 mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES); ··· 750 746 Status interrupt.\n"); 751 747 } 752 748 753 - if (uart->cts_pin >= 0) { 754 - gpio_request(uart->cts_pin, DRIVER_NAME); 755 - gpio_direction_output(uart->cts_pin, 1); 756 - } 757 - if (uart->rts_pin >= 0) { 758 - gpio_request(uart->rts_pin, DRIVER_NAME); 759 - gpio_direction_output(uart->rts_pin, 0); 760 - } 761 - 762 749 /* CTS RTS PINs are negative assertive. */ 763 750 UART_PUT_MCR(uart, ACTS); 764 751 UART_SET_IER(uart, EDSSI); ··· 796 801 gpio_free(uart->rts_pin); 797 802 #endif 798 803 #ifdef CONFIG_SERIAL_BFIN_HARD_CTSRTS 799 - if (uart->cts_pin >= 0) 800 - gpio_free(uart->cts_pin); 801 - if (uart->rts_pin >= 0) 802 - gpio_free(uart->rts_pin); 803 804 if (UART_GET_IER(uart) && EDSSI) 804 805 free_irq(uart->status_irq, uart); 805 806 #endif ··· 1400 1409 continue; 1401 1410 uart_remove_one_port(&bfin_serial_reg, &bfin_serial_ports[i].port); 1402 1411 bfin_serial_ports[i].port.dev = NULL; 1403 - #if defined(CONFIG_SERIAL_BFIN_CTSRTS) || \ 1404 - defined(CONFIG_SERIAL_BFIN_HARD_CTSRTS) 1412 + #if defined(CONFIG_SERIAL_BFIN_CTSRTS) 1405 1413 gpio_free(bfin_serial_ports[i].cts_pin); 1406 1414 gpio_free(bfin_serial_ports[i].rts_pin); 1407 1415 #endif
+470 -233
drivers/serial/bfin_sport_uart.c
··· 1 1 /* 2 - * File: linux/drivers/serial/bfin_sport_uart.c 2 + * Blackfin On-Chip Sport Emulated UART Driver 3 3 * 4 - * Based on: drivers/serial/bfin_5xx.c by Aubrey Li. 5 - * Author: Roy Huang <roy.huang@analog.com> 4 + * Copyright 2006-2009 Analog Devices Inc. 6 5 * 7 - * Created: Nov 22, 2006 8 - * Copyright: (c) 2006-2007 Analog Devices Inc. 9 - * Description: this driver enable SPORTs on Blackfin emulate UART. 6 + * Enter bugs at http://blackfin.uclinux.org/ 10 7 * 11 - * This program is free software; you can redistribute it and/or modify 12 - * it under the terms of the GNU General Public License as published by 13 - * the Free Software Foundation; either version 2 of the License, or 14 - * (at your option) any later version. 15 - * 16 - * This program is distributed in the hope that it will be useful, 17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 - * GNU General Public License for more details. 20 - * 21 - * You should have received a copy of the GNU General Public License 22 - * along with this program; if not, see the file COPYING, or write 23 - * to the Free Software Foundation, Inc., 24 - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 8 + * Licensed under the GPL-2 or later. 25 9 */ 26 10 27 11 /* ··· 13 29 * http://www.analog.com/UploadedFiles/Application_Notes/399447663EE191.pdf 14 30 * This application note describe how to implement a UART on a Sharc DSP, 15 31 * but this driver is implemented on Blackfin Processor. 32 + * Transmit Frame Sync is not used by this driver to transfer data out. 16 33 */ 17 34 18 - /* After reset, there is a prelude of low level pulse when transmit data first 19 - * time. No addtional pulse in following transmit. 20 - * According to document: 21 - * The SPORTs are ready to start transmitting or receiving data no later than 22 - * three serial clock cycles after they are enabled in the SPORTx_TCR1 or 23 - * SPORTx_RCR1 register. No serial clock cycles are lost from this point on. 24 - * The first internal frame sync will occur one frame sync delay after the 25 - * SPORTs are ready. External frame syncs can occur as soon as the SPORT is 26 - * ready. 27 - */ 35 + /* #define DEBUG */ 28 36 29 - /* Thanks to Axel Alatalo <axel@rubico.se> for fixing sport rx bug. Sometimes 30 - * sport receives data incorrectly. The following is Axel's words. 31 - * As EE-191, sport rx samples 3 times of the UART baudrate and takes the 32 - * middle smaple of every 3 samples as the data bit. For a 8-N-1 UART setting, 33 - * 30 samples will be required for a byte. If transmitter sends a 1/3 bit short 34 - * byte due to buadrate drift, then the 30th sample of a byte, this sample is 35 - * also the third sample of the stop bit, will happens on the immediately 36 - * following start bit which will be thrown away and missed. Thus since parts 37 - * of the startbit will be missed and the receiver will begin to drift, the 38 - * effect accumulates over time until synchronization is lost. 39 - * If only require 2 samples of the stopbit (by sampling in total 29 samples), 40 - * then a to short byte as in the case above will be tolerated. Then the 1/3 41 - * early startbit will trigger a framesync since the last read is complete 42 - * after only 2/3 stopbit and framesync is active during the last 1/3 looking 43 - * for a possible early startbit. */ 44 - 45 - //#define DEBUG 37 + #define DRV_NAME "bfin-sport-uart" 38 + #define DEVICE_NAME "ttySS" 39 + #define pr_fmt(fmt) DRV_NAME ": " fmt 46 40 47 41 #include <linux/module.h> 48 42 #include <linux/ioport.h> 43 + #include <linux/io.h> 49 44 #include <linux/init.h> 50 45 #include <linux/console.h> 51 46 #include <linux/sysrq.h> ··· 38 75 39 76 #include "bfin_sport_uart.h" 40 77 78 + #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART 41 79 unsigned short bfin_uart_pin_req_sport0[] = 42 80 {P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, \ 43 81 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0}; 44 - 82 + #endif 83 + #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART 45 84 unsigned short bfin_uart_pin_req_sport1[] = 46 85 {P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, \ 47 86 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0}; 48 - 49 - #define DRV_NAME "bfin-sport-uart" 87 + #endif 88 + #ifdef CONFIG_SERIAL_BFIN_SPORT2_UART 89 + unsigned short bfin_uart_pin_req_sport2[] = 90 + {P_SPORT2_TFS, P_SPORT2_DTPRI, P_SPORT2_TSCLK, P_SPORT2_RFS, \ 91 + P_SPORT2_DRPRI, P_SPORT2_RSCLK, P_SPORT2_DRSEC, P_SPORT2_DTSEC, 0}; 92 + #endif 93 + #ifdef CONFIG_SERIAL_BFIN_SPORT3_UART 94 + unsigned short bfin_uart_pin_req_sport3[] = 95 + {P_SPORT3_TFS, P_SPORT3_DTPRI, P_SPORT3_TSCLK, P_SPORT3_RFS, \ 96 + P_SPORT3_DRPRI, P_SPORT3_RSCLK, P_SPORT3_DRSEC, P_SPORT3_DTSEC, 0}; 97 + #endif 50 98 51 99 struct sport_uart_port { 52 100 struct uart_port port; 53 - char *name; 54 - 55 - int tx_irq; 56 - int rx_irq; 57 101 int err_irq; 102 + unsigned short csize; 103 + unsigned short rxmask; 104 + unsigned short txmask1; 105 + unsigned short txmask2; 106 + unsigned char stopb; 107 + /* unsigned char parib; */ 58 108 }; 59 109 60 110 static void sport_uart_tx_chars(struct sport_uart_port *up); ··· 75 99 76 100 static inline void tx_one_byte(struct sport_uart_port *up, unsigned int value) 77 101 { 78 - pr_debug("%s value:%x\n", __func__, value); 79 - /* Place a Start and Stop bit */ 102 + pr_debug("%s value:%x, mask1=0x%x, mask2=0x%x\n", __func__, value, 103 + up->txmask1, up->txmask2); 104 + 105 + /* Place Start and Stop bits */ 80 106 __asm__ __volatile__ ( 81 - "R2 = b#01111111100;" 82 - "R3 = b#10000000001;" 83 - "%0 <<= 2;" 84 - "%0 = %0 & R2;" 85 - "%0 = %0 | R3;" 86 - : "=d"(value) 87 - : "d"(value) 88 - : "ASTAT", "R2", "R3" 107 + "%[val] <<= 1;" 108 + "%[val] = %[val] & %[mask1];" 109 + "%[val] = %[val] | %[mask2];" 110 + : [val]"+d"(value) 111 + : [mask1]"d"(up->txmask1), [mask2]"d"(up->txmask2) 112 + : "ASTAT" 89 113 ); 90 114 pr_debug("%s value:%x\n", __func__, value); 91 115 92 116 SPORT_PUT_TX(up, value); 93 117 } 94 118 95 - static inline unsigned int rx_one_byte(struct sport_uart_port *up) 119 + static inline unsigned char rx_one_byte(struct sport_uart_port *up) 96 120 { 97 - unsigned int value, extract; 121 + unsigned int value; 122 + unsigned char extract; 98 123 u32 tmp_mask1, tmp_mask2, tmp_shift, tmp; 99 124 100 - value = SPORT_GET_RX32(up); 101 - pr_debug("%s value:%x\n", __func__, value); 125 + if ((up->csize + up->stopb) > 7) 126 + value = SPORT_GET_RX32(up); 127 + else 128 + value = SPORT_GET_RX(up); 102 129 103 - /* Extract 8 bits data */ 130 + pr_debug("%s value:%x, cs=%d, mask=0x%x\n", __func__, value, 131 + up->csize, up->rxmask); 132 + 133 + /* Extract data */ 104 134 __asm__ __volatile__ ( 105 135 "%[extr] = 0;" 106 - "%[mask1] = 0x1801(Z);" 107 - "%[mask2] = 0x0300(Z);" 136 + "%[mask1] = %[rxmask];" 137 + "%[mask2] = 0x0200(Z);" 108 138 "%[shift] = 0;" 109 139 "LSETUP(.Lloop_s, .Lloop_e) LC0 = %[lc];" 110 140 ".Lloop_s:" ··· 120 138 "%[mask1] = %[mask1] - %[mask2];" 121 139 ".Lloop_e:" 122 140 "%[shift] += 1;" 123 - : [val]"=d"(value), [extr]"=d"(extract), [shift]"=d"(tmp_shift), [tmp]"=d"(tmp), 124 - [mask1]"=d"(tmp_mask1), [mask2]"=d"(tmp_mask2) 125 - : "d"(value), [lc]"a"(8) 141 + : [extr]"=&d"(extract), [shift]"=&d"(tmp_shift), [tmp]"=&d"(tmp), 142 + [mask1]"=&d"(tmp_mask1), [mask2]"=&d"(tmp_mask2) 143 + : [val]"d"(value), [rxmask]"d"(up->rxmask), [lc]"a"(up->csize) 126 144 : "ASTAT", "LB0", "LC0", "LT0" 127 145 ); 128 146 ··· 130 148 return extract; 131 149 } 132 150 133 - static int sport_uart_setup(struct sport_uart_port *up, int sclk, int baud_rate) 151 + static int sport_uart_setup(struct sport_uart_port *up, int size, int baud_rate) 134 152 { 135 - int tclkdiv, tfsdiv, rclkdiv; 153 + int tclkdiv, rclkdiv; 154 + unsigned int sclk = get_sclk(); 136 155 137 - /* Set TCR1 and TCR2 */ 138 - SPORT_PUT_TCR1(up, (LATFS | ITFS | TFSR | TLSBIT | ITCLK)); 139 - SPORT_PUT_TCR2(up, 10); 156 + /* Set TCR1 and TCR2, TFSR is not enabled for uart */ 157 + SPORT_PUT_TCR1(up, (ITFS | TLSBIT | ITCLK)); 158 + SPORT_PUT_TCR2(up, size + 1); 140 159 pr_debug("%s TCR1:%x, TCR2:%x\n", __func__, SPORT_GET_TCR1(up), SPORT_GET_TCR2(up)); 141 160 142 161 /* Set RCR1 and RCR2 */ 143 162 SPORT_PUT_RCR1(up, (RCKFE | LARFS | LRFS | RFSR | IRCLK)); 144 - SPORT_PUT_RCR2(up, 28); 163 + SPORT_PUT_RCR2(up, (size + 1) * 2 - 1); 145 164 pr_debug("%s RCR1:%x, RCR2:%x\n", __func__, SPORT_GET_RCR1(up), SPORT_GET_RCR2(up)); 146 165 147 - tclkdiv = sclk/(2 * baud_rate) - 1; 148 - tfsdiv = 12; 149 - rclkdiv = sclk/(2 * baud_rate * 3) - 1; 166 + tclkdiv = sclk / (2 * baud_rate) - 1; 167 + rclkdiv = sclk / (2 * baud_rate * 2) - 1; 150 168 SPORT_PUT_TCLKDIV(up, tclkdiv); 151 - SPORT_PUT_TFSDIV(up, tfsdiv); 152 169 SPORT_PUT_RCLKDIV(up, rclkdiv); 153 170 SSYNC(); 154 - pr_debug("%s sclk:%d, baud_rate:%d, tclkdiv:%d, tfsdiv:%d, rclkdiv:%d\n", 155 - __func__, sclk, baud_rate, tclkdiv, tfsdiv, rclkdiv); 171 + pr_debug("%s sclk:%d, baud_rate:%d, tclkdiv:%d, rclkdiv:%d\n", 172 + __func__, sclk, baud_rate, tclkdiv, rclkdiv); 156 173 157 174 return 0; 158 175 } ··· 162 181 struct tty_struct *tty = up->port.state->port.tty; 163 182 unsigned int ch; 164 183 165 - do { 184 + spin_lock(&up->port.lock); 185 + 186 + while (SPORT_GET_STAT(up) & RXNE) { 166 187 ch = rx_one_byte(up); 167 188 up->port.icount.rx++; 168 189 169 - if (uart_handle_sysrq_char(&up->port, ch)) 170 - ; 171 - else 190 + if (!uart_handle_sysrq_char(&up->port, ch)) 172 191 tty_insert_flip_char(tty, ch, TTY_NORMAL); 173 - } while (SPORT_GET_STAT(up) & RXNE); 192 + } 174 193 tty_flip_buffer_push(tty); 194 + 195 + spin_unlock(&up->port.lock); 175 196 176 197 return IRQ_HANDLED; 177 198 } 178 199 179 200 static irqreturn_t sport_uart_tx_irq(int irq, void *dev_id) 180 201 { 181 - sport_uart_tx_chars(dev_id); 202 + struct sport_uart_port *up = dev_id; 203 + 204 + spin_lock(&up->port.lock); 205 + sport_uart_tx_chars(up); 206 + spin_unlock(&up->port.lock); 182 207 183 208 return IRQ_HANDLED; 184 209 } ··· 195 208 struct tty_struct *tty = up->port.state->port.tty; 196 209 unsigned int stat = SPORT_GET_STAT(up); 197 210 211 + spin_lock(&up->port.lock); 212 + 198 213 /* Overflow in RX FIFO */ 199 214 if (stat & ROVF) { 200 215 up->port.icount.overrun++; ··· 205 216 } 206 217 /* These should not happen */ 207 218 if (stat & (TOVF | TUVF | RUVF)) { 208 - printk(KERN_ERR "SPORT Error:%s %s %s\n", 209 - (stat & TOVF)?"TX overflow":"", 210 - (stat & TUVF)?"TX underflow":"", 211 - (stat & RUVF)?"RX underflow":""); 219 + pr_err("SPORT Error:%s %s %s\n", 220 + (stat & TOVF) ? "TX overflow" : "", 221 + (stat & TUVF) ? "TX underflow" : "", 222 + (stat & RUVF) ? "RX underflow" : ""); 212 223 SPORT_PUT_TCR1(up, SPORT_GET_TCR1(up) & ~TSPEN); 213 224 SPORT_PUT_RCR1(up, SPORT_GET_RCR1(up) & ~RSPEN); 214 225 } 215 226 SSYNC(); 216 227 228 + spin_unlock(&up->port.lock); 217 229 return IRQ_HANDLED; 218 230 } 219 231 ··· 222 232 static int sport_startup(struct uart_port *port) 223 233 { 224 234 struct sport_uart_port *up = (struct sport_uart_port *)port; 225 - char buffer[20]; 226 - int retval; 235 + int ret; 227 236 228 237 pr_debug("%s enter\n", __func__); 229 - snprintf(buffer, 20, "%s rx", up->name); 230 - retval = request_irq(up->rx_irq, sport_uart_rx_irq, IRQF_SAMPLE_RANDOM, buffer, up); 231 - if (retval) { 232 - printk(KERN_ERR "Unable to request interrupt %s\n", buffer); 233 - return retval; 238 + ret = request_irq(up->port.irq, sport_uart_rx_irq, 0, 239 + "SPORT_UART_RX", up); 240 + if (ret) { 241 + dev_err(port->dev, "unable to request SPORT RX interrupt\n"); 242 + return ret; 234 243 } 235 244 236 - snprintf(buffer, 20, "%s tx", up->name); 237 - retval = request_irq(up->tx_irq, sport_uart_tx_irq, IRQF_SAMPLE_RANDOM, buffer, up); 238 - if (retval) { 239 - printk(KERN_ERR "Unable to request interrupt %s\n", buffer); 245 + ret = request_irq(up->port.irq+1, sport_uart_tx_irq, 0, 246 + "SPORT_UART_TX", up); 247 + if (ret) { 248 + dev_err(port->dev, "unable to request SPORT TX interrupt\n"); 240 249 goto fail1; 241 250 } 242 251 243 - snprintf(buffer, 20, "%s err", up->name); 244 - retval = request_irq(up->err_irq, sport_uart_err_irq, IRQF_SAMPLE_RANDOM, buffer, up); 245 - if (retval) { 246 - printk(KERN_ERR "Unable to request interrupt %s\n", buffer); 252 + ret = request_irq(up->err_irq, sport_uart_err_irq, 0, 253 + "SPORT_UART_STATUS", up); 254 + if (ret) { 255 + dev_err(port->dev, "unable to request SPORT status interrupt\n"); 247 256 goto fail2; 248 257 } 249 258 250 - if (port->line) { 251 - if (peripheral_request_list(bfin_uart_pin_req_sport1, DRV_NAME)) 252 - goto fail3; 253 - } else { 254 - if (peripheral_request_list(bfin_uart_pin_req_sport0, DRV_NAME)) 255 - goto fail3; 256 - } 257 - 258 - sport_uart_setup(up, get_sclk(), port->uartclk); 259 - 260 - /* Enable receive interrupt */ 261 - SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) | RSPEN)); 262 - SSYNC(); 263 - 264 259 return 0; 260 + fail2: 261 + free_irq(up->port.irq+1, up); 262 + fail1: 263 + free_irq(up->port.irq, up); 265 264 266 - 267 - fail3: 268 - printk(KERN_ERR DRV_NAME 269 - ": Requesting Peripherals failed\n"); 270 - 271 - free_irq(up->err_irq, up); 272 - fail2: 273 - free_irq(up->tx_irq, up); 274 - fail1: 275 - free_irq(up->rx_irq, up); 276 - 277 - return retval; 278 - 265 + return ret; 279 266 } 280 267 281 268 static void sport_uart_tx_chars(struct sport_uart_port *up) ··· 311 344 static void sport_stop_tx(struct uart_port *port) 312 345 { 313 346 struct sport_uart_port *up = (struct sport_uart_port *)port; 314 - unsigned int stat; 315 347 316 348 pr_debug("%s enter\n", __func__); 317 349 318 - stat = SPORT_GET_STAT(up); 319 - while(!(stat & TXHRE)) { 320 - udelay(1); 321 - stat = SPORT_GET_STAT(up); 322 - } 323 350 /* Although the hold register is empty, last byte is still in shift 324 - * register and not sent out yet. If baud rate is lower than default, 325 - * delay should be longer. For example, if the baud rate is 9600, 326 - * the delay must be at least 2ms by experience */ 327 - udelay(500); 351 + * register and not sent out yet. So, put a dummy data into TX FIFO. 352 + * Then, sport tx stops when last byte is shift out and the dummy 353 + * data is moved into the shift register. 354 + */ 355 + SPORT_PUT_TX(up, 0xffff); 356 + while (!(SPORT_GET_STAT(up) & TXHRE)) 357 + cpu_relax(); 328 358 329 359 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) & ~TSPEN)); 330 360 SSYNC(); ··· 334 370 struct sport_uart_port *up = (struct sport_uart_port *)port; 335 371 336 372 pr_debug("%s enter\n", __func__); 373 + 337 374 /* Write data into SPORT FIFO before enable SPROT to transmit */ 338 375 sport_uart_tx_chars(up); 339 376 ··· 368 403 { 369 404 struct sport_uart_port *up = (struct sport_uart_port *)port; 370 405 371 - pr_debug("%s enter\n", __func__); 406 + dev_dbg(port->dev, "%s enter\n", __func__); 372 407 373 408 /* Disable sport */ 374 409 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) & ~TSPEN)); 375 410 SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) & ~RSPEN)); 376 411 SSYNC(); 377 412 378 - if (port->line) { 379 - peripheral_free_list(bfin_uart_pin_req_sport1); 380 - } else { 381 - peripheral_free_list(bfin_uart_pin_req_sport0); 382 - } 383 - 384 - free_irq(up->rx_irq, up); 385 - free_irq(up->tx_irq, up); 413 + free_irq(up->port.irq, up); 414 + free_irq(up->port.irq+1, up); 386 415 free_irq(up->err_irq, up); 387 - } 388 - 389 - static void sport_set_termios(struct uart_port *port, 390 - struct ktermios *termios, struct ktermios *old) 391 - { 392 - pr_debug("%s enter, c_cflag:%08x\n", __func__, termios->c_cflag); 393 - uart_update_timeout(port, CS8 ,port->uartclk); 394 416 } 395 417 396 418 static const char *sport_type(struct uart_port *port) ··· 385 433 struct sport_uart_port *up = (struct sport_uart_port *)port; 386 434 387 435 pr_debug("%s enter\n", __func__); 388 - return up->name; 436 + return up->port.type == PORT_BFIN_SPORT ? "BFIN-SPORT-UART" : NULL; 389 437 } 390 438 391 439 static void sport_release_port(struct uart_port *port) ··· 413 461 return 0; 414 462 } 415 463 464 + static void sport_set_termios(struct uart_port *port, 465 + struct ktermios *termios, struct ktermios *old) 466 + { 467 + struct sport_uart_port *up = (struct sport_uart_port *)port; 468 + unsigned long flags; 469 + int i; 470 + 471 + pr_debug("%s enter, c_cflag:%08x\n", __func__, termios->c_cflag); 472 + 473 + switch (termios->c_cflag & CSIZE) { 474 + case CS8: 475 + up->csize = 8; 476 + break; 477 + case CS7: 478 + up->csize = 7; 479 + break; 480 + case CS6: 481 + up->csize = 6; 482 + break; 483 + case CS5: 484 + up->csize = 5; 485 + break; 486 + default: 487 + pr_warning("requested word length not supported\n"); 488 + } 489 + 490 + if (termios->c_cflag & CSTOPB) { 491 + up->stopb = 1; 492 + } 493 + if (termios->c_cflag & PARENB) { 494 + pr_warning("PAREN bits is not supported yet\n"); 495 + /* up->parib = 1; */ 496 + } 497 + 498 + port->read_status_mask = OE; 499 + if (termios->c_iflag & INPCK) 500 + port->read_status_mask |= (FE | PE); 501 + if (termios->c_iflag & (BRKINT | PARMRK)) 502 + port->read_status_mask |= BI; 503 + 504 + /* 505 + * Characters to ignore 506 + */ 507 + port->ignore_status_mask = 0; 508 + if (termios->c_iflag & IGNPAR) 509 + port->ignore_status_mask |= FE | PE; 510 + if (termios->c_iflag & IGNBRK) { 511 + port->ignore_status_mask |= BI; 512 + /* 513 + * If we're ignoring parity and break indicators, 514 + * ignore overruns too (for real raw support). 515 + */ 516 + if (termios->c_iflag & IGNPAR) 517 + port->ignore_status_mask |= OE; 518 + } 519 + 520 + /* RX extract mask */ 521 + up->rxmask = 0x01 | (((up->csize + up->stopb) * 2 - 1) << 0x8); 522 + /* TX masks, 8 bit data and 1 bit stop for example: 523 + * mask1 = b#0111111110 524 + * mask2 = b#1000000000 525 + */ 526 + for (i = 0, up->txmask1 = 0; i < up->csize; i++) 527 + up->txmask1 |= (1<<i); 528 + up->txmask2 = (1<<i); 529 + if (up->stopb) { 530 + ++i; 531 + up->txmask2 |= (1<<i); 532 + } 533 + up->txmask1 <<= 1; 534 + up->txmask2 <<= 1; 535 + /* uart baud rate */ 536 + port->uartclk = uart_get_baud_rate(port, termios, old, 0, get_sclk()/16); 537 + 538 + spin_lock_irqsave(&up->port.lock, flags); 539 + 540 + /* Disable UART */ 541 + SPORT_PUT_TCR1(up, SPORT_GET_TCR1(up) & ~TSPEN); 542 + SPORT_PUT_RCR1(up, SPORT_GET_RCR1(up) & ~RSPEN); 543 + 544 + sport_uart_setup(up, up->csize + up->stopb, port->uartclk); 545 + 546 + /* driver TX line high after config, one dummy data is 547 + * necessary to stop sport after shift one byte 548 + */ 549 + SPORT_PUT_TX(up, 0xffff); 550 + SPORT_PUT_TX(up, 0xffff); 551 + SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) | TSPEN)); 552 + SSYNC(); 553 + while (!(SPORT_GET_STAT(up) & TXHRE)) 554 + cpu_relax(); 555 + SPORT_PUT_TCR1(up, SPORT_GET_TCR1(up) & ~TSPEN); 556 + SSYNC(); 557 + 558 + /* Port speed changed, update the per-port timeout. */ 559 + uart_update_timeout(port, termios->c_cflag, port->uartclk); 560 + 561 + /* Enable sport rx */ 562 + SPORT_PUT_RCR1(up, SPORT_GET_RCR1(up) | RSPEN); 563 + SSYNC(); 564 + 565 + spin_unlock_irqrestore(&up->port.lock, flags); 566 + } 567 + 416 568 struct uart_ops sport_uart_ops = { 417 569 .tx_empty = sport_tx_empty, 418 570 .set_mctrl = sport_set_mctrl, ··· 536 480 .verify_port = sport_verify_port, 537 481 }; 538 482 539 - static struct sport_uart_port sport_uart_ports[] = { 540 - { /* SPORT 0 */ 541 - .name = "SPORT0", 542 - .tx_irq = IRQ_SPORT0_TX, 543 - .rx_irq = IRQ_SPORT0_RX, 544 - .err_irq= IRQ_SPORT0_ERROR, 545 - .port = { 546 - .type = PORT_BFIN_SPORT, 547 - .iotype = UPIO_MEM, 548 - .membase = (void __iomem *)SPORT0_TCR1, 549 - .mapbase = SPORT0_TCR1, 550 - .irq = IRQ_SPORT0_RX, 551 - .uartclk = CONFIG_SPORT_BAUD_RATE, 552 - .fifosize = 8, 553 - .ops = &sport_uart_ops, 554 - .line = 0, 555 - }, 556 - }, { /* SPORT 1 */ 557 - .name = "SPORT1", 558 - .tx_irq = IRQ_SPORT1_TX, 559 - .rx_irq = IRQ_SPORT1_RX, 560 - .err_irq= IRQ_SPORT1_ERROR, 561 - .port = { 562 - .type = PORT_BFIN_SPORT, 563 - .iotype = UPIO_MEM, 564 - .membase = (void __iomem *)SPORT1_TCR1, 565 - .mapbase = SPORT1_TCR1, 566 - .irq = IRQ_SPORT1_RX, 567 - .uartclk = CONFIG_SPORT_BAUD_RATE, 568 - .fifosize = 8, 569 - .ops = &sport_uart_ops, 570 - .line = 1, 571 - }, 483 + #define BFIN_SPORT_UART_MAX_PORTS 4 484 + 485 + static struct sport_uart_port *bfin_sport_uart_ports[BFIN_SPORT_UART_MAX_PORTS]; 486 + 487 + #ifdef CONFIG_SERIAL_BFIN_SPORT_CONSOLE 488 + static int __init 489 + sport_uart_console_setup(struct console *co, char *options) 490 + { 491 + struct sport_uart_port *up; 492 + int baud = 57600; 493 + int bits = 8; 494 + int parity = 'n'; 495 + int flow = 'n'; 496 + 497 + /* Check whether an invalid uart number has been specified */ 498 + if (co->index < 0 || co->index >= BFIN_SPORT_UART_MAX_PORTS) 499 + return -ENODEV; 500 + 501 + up = bfin_sport_uart_ports[co->index]; 502 + if (!up) 503 + return -ENODEV; 504 + 505 + if (options) 506 + uart_parse_options(options, &baud, &parity, &bits, &flow); 507 + 508 + return uart_set_options(&up->port, co, baud, parity, bits, flow); 509 + } 510 + 511 + static void sport_uart_console_putchar(struct uart_port *port, int ch) 512 + { 513 + struct sport_uart_port *up = (struct sport_uart_port *)port; 514 + 515 + while (SPORT_GET_STAT(up) & TXF) 516 + barrier(); 517 + 518 + tx_one_byte(up, ch); 519 + } 520 + 521 + /* 522 + * Interrupts are disabled on entering 523 + */ 524 + static void 525 + sport_uart_console_write(struct console *co, const char *s, unsigned int count) 526 + { 527 + struct sport_uart_port *up = bfin_sport_uart_ports[co->index]; 528 + unsigned long flags; 529 + 530 + spin_lock_irqsave(&up->port.lock, flags); 531 + 532 + if (SPORT_GET_TCR1(up) & TSPEN) 533 + uart_console_write(&up->port, s, count, sport_uart_console_putchar); 534 + else { 535 + /* dummy data to start sport */ 536 + while (SPORT_GET_STAT(up) & TXF) 537 + barrier(); 538 + SPORT_PUT_TX(up, 0xffff); 539 + /* Enable transmit, then an interrupt will generated */ 540 + SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) | TSPEN)); 541 + SSYNC(); 542 + 543 + uart_console_write(&up->port, s, count, sport_uart_console_putchar); 544 + 545 + /* Although the hold register is empty, last byte is still in shift 546 + * register and not sent out yet. So, put a dummy data into TX FIFO. 547 + * Then, sport tx stops when last byte is shift out and the dummy 548 + * data is moved into the shift register. 549 + */ 550 + while (SPORT_GET_STAT(up) & TXF) 551 + barrier(); 552 + SPORT_PUT_TX(up, 0xffff); 553 + while (!(SPORT_GET_STAT(up) & TXHRE)) 554 + barrier(); 555 + 556 + /* Stop sport tx transfer */ 557 + SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) & ~TSPEN)); 558 + SSYNC(); 572 559 } 560 + 561 + spin_unlock_irqrestore(&up->port.lock, flags); 562 + } 563 + 564 + static struct uart_driver sport_uart_reg; 565 + 566 + static struct console sport_uart_console = { 567 + .name = DEVICE_NAME, 568 + .write = sport_uart_console_write, 569 + .device = uart_console_device, 570 + .setup = sport_uart_console_setup, 571 + .flags = CON_PRINTBUFFER, 572 + .index = -1, 573 + .data = &sport_uart_reg, 573 574 }; 575 + 576 + #define SPORT_UART_CONSOLE (&sport_uart_console) 577 + #else 578 + #define SPORT_UART_CONSOLE NULL 579 + #endif /* CONFIG_SERIAL_BFIN_SPORT_CONSOLE */ 580 + 574 581 575 582 static struct uart_driver sport_uart_reg = { 576 583 .owner = THIS_MODULE, 577 - .driver_name = "SPORT-UART", 578 - .dev_name = "ttySS", 584 + .driver_name = DRV_NAME, 585 + .dev_name = DEVICE_NAME, 579 586 .major = 204, 580 587 .minor = 84, 581 - .nr = ARRAY_SIZE(sport_uart_ports), 582 - .cons = NULL, 588 + .nr = BFIN_SPORT_UART_MAX_PORTS, 589 + .cons = SPORT_UART_CONSOLE, 583 590 }; 584 591 585 - static int sport_uart_suspend(struct platform_device *dev, pm_message_t state) 592 + #ifdef CONFIG_PM 593 + static int sport_uart_suspend(struct device *dev) 586 594 { 587 - struct sport_uart_port *sport = platform_get_drvdata(dev); 595 + struct sport_uart_port *sport = dev_get_drvdata(dev); 588 596 589 - pr_debug("%s enter\n", __func__); 597 + dev_dbg(dev, "%s enter\n", __func__); 590 598 if (sport) 591 599 uart_suspend_port(&sport_uart_reg, &sport->port); 592 600 593 601 return 0; 594 602 } 595 603 596 - static int sport_uart_resume(struct platform_device *dev) 604 + static int sport_uart_resume(struct device *dev) 597 605 { 598 - struct sport_uart_port *sport = platform_get_drvdata(dev); 606 + struct sport_uart_port *sport = dev_get_drvdata(dev); 599 607 600 - pr_debug("%s enter\n", __func__); 608 + dev_dbg(dev, "%s enter\n", __func__); 601 609 if (sport) 602 610 uart_resume_port(&sport_uart_reg, &sport->port); 603 611 604 612 return 0; 605 613 } 606 614 607 - static int sport_uart_probe(struct platform_device *dev) 608 - { 609 - pr_debug("%s enter\n", __func__); 610 - sport_uart_ports[dev->id].port.dev = &dev->dev; 611 - uart_add_one_port(&sport_uart_reg, &sport_uart_ports[dev->id].port); 612 - platform_set_drvdata(dev, &sport_uart_ports[dev->id]); 615 + static struct dev_pm_ops bfin_sport_uart_dev_pm_ops = { 616 + .suspend = sport_uart_suspend, 617 + .resume = sport_uart_resume, 618 + }; 619 + #endif 613 620 614 - return 0; 621 + static int __devinit sport_uart_probe(struct platform_device *pdev) 622 + { 623 + struct resource *res; 624 + struct sport_uart_port *sport; 625 + int ret = 0; 626 + 627 + dev_dbg(&pdev->dev, "%s enter\n", __func__); 628 + 629 + if (pdev->id < 0 || pdev->id >= BFIN_SPORT_UART_MAX_PORTS) { 630 + dev_err(&pdev->dev, "Wrong sport uart platform device id.\n"); 631 + return -ENOENT; 632 + } 633 + 634 + if (bfin_sport_uart_ports[pdev->id] == NULL) { 635 + bfin_sport_uart_ports[pdev->id] = 636 + kmalloc(sizeof(struct sport_uart_port), GFP_KERNEL); 637 + sport = bfin_sport_uart_ports[pdev->id]; 638 + if (!sport) { 639 + dev_err(&pdev->dev, 640 + "Fail to kmalloc sport_uart_port\n"); 641 + return -ENOMEM; 642 + } 643 + 644 + ret = peripheral_request_list( 645 + (unsigned short *)pdev->dev.platform_data, DRV_NAME); 646 + if (ret) { 647 + dev_err(&pdev->dev, 648 + "Fail to request SPORT peripherals\n"); 649 + goto out_error_free_mem; 650 + } 651 + 652 + spin_lock_init(&sport->port.lock); 653 + sport->port.fifosize = SPORT_TX_FIFO_SIZE, 654 + sport->port.ops = &sport_uart_ops; 655 + sport->port.line = pdev->id; 656 + sport->port.iotype = UPIO_MEM; 657 + sport->port.flags = UPF_BOOT_AUTOCONF; 658 + 659 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 660 + if (res == NULL) { 661 + dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n"); 662 + ret = -ENOENT; 663 + goto out_error_free_peripherals; 664 + } 665 + 666 + sport->port.membase = ioremap(res->start, 667 + res->end - res->start); 668 + if (!sport->port.membase) { 669 + dev_err(&pdev->dev, "Cannot map sport IO\n"); 670 + ret = -ENXIO; 671 + goto out_error_free_peripherals; 672 + } 673 + 674 + sport->port.irq = platform_get_irq(pdev, 0); 675 + if (sport->port.irq < 0) { 676 + dev_err(&pdev->dev, "No sport RX/TX IRQ specified\n"); 677 + ret = -ENOENT; 678 + goto out_error_unmap; 679 + } 680 + 681 + sport->err_irq = platform_get_irq(pdev, 1); 682 + if (sport->err_irq < 0) { 683 + dev_err(&pdev->dev, "No sport status IRQ specified\n"); 684 + ret = -ENOENT; 685 + goto out_error_unmap; 686 + } 687 + } 688 + 689 + #ifdef CONFIG_SERIAL_BFIN_SPORT_CONSOLE 690 + if (!is_early_platform_device(pdev)) { 691 + #endif 692 + sport = bfin_sport_uart_ports[pdev->id]; 693 + sport->port.dev = &pdev->dev; 694 + dev_set_drvdata(&pdev->dev, sport); 695 + ret = uart_add_one_port(&sport_uart_reg, &sport->port); 696 + #ifdef CONFIG_SERIAL_BFIN_SPORT_CONSOLE 697 + } 698 + #endif 699 + if (!ret) 700 + return 0; 701 + 702 + if (sport) { 703 + out_error_unmap: 704 + iounmap(sport->port.membase); 705 + out_error_free_peripherals: 706 + peripheral_free_list( 707 + (unsigned short *)pdev->dev.platform_data); 708 + out_error_free_mem: 709 + kfree(sport); 710 + bfin_sport_uart_ports[pdev->id] = NULL; 711 + } 712 + 713 + return ret; 615 714 } 616 715 617 - static int sport_uart_remove(struct platform_device *dev) 716 + static int __devexit sport_uart_remove(struct platform_device *pdev) 618 717 { 619 - struct sport_uart_port *sport = platform_get_drvdata(dev); 718 + struct sport_uart_port *sport = platform_get_drvdata(pdev); 620 719 621 - pr_debug("%s enter\n", __func__); 622 - platform_set_drvdata(dev, NULL); 720 + dev_dbg(&pdev->dev, "%s enter\n", __func__); 721 + dev_set_drvdata(&pdev->dev, NULL); 623 722 624 - if (sport) 723 + if (sport) { 625 724 uart_remove_one_port(&sport_uart_reg, &sport->port); 725 + iounmap(sport->port.membase); 726 + peripheral_free_list( 727 + (unsigned short *)pdev->dev.platform_data); 728 + kfree(sport); 729 + bfin_sport_uart_ports[pdev->id] = NULL; 730 + } 626 731 627 732 return 0; 628 733 } 629 734 630 735 static struct platform_driver sport_uart_driver = { 631 736 .probe = sport_uart_probe, 632 - .remove = sport_uart_remove, 633 - .suspend = sport_uart_suspend, 634 - .resume = sport_uart_resume, 737 + .remove = __devexit_p(sport_uart_remove), 635 738 .driver = { 636 739 .name = DRV_NAME, 740 + #ifdef CONFIG_PM 741 + .pm = &bfin_sport_uart_dev_pm_ops, 742 + #endif 637 743 }, 638 744 }; 745 + 746 + #ifdef CONFIG_SERIAL_BFIN_SPORT_CONSOLE 747 + static __initdata struct early_platform_driver early_sport_uart_driver = { 748 + .class_str = DRV_NAME, 749 + .pdrv = &sport_uart_driver, 750 + .requested_id = EARLY_PLATFORM_ID_UNSET, 751 + }; 752 + 753 + static int __init sport_uart_rs_console_init(void) 754 + { 755 + early_platform_driver_register(&early_sport_uart_driver, DRV_NAME); 756 + 757 + early_platform_driver_probe(DRV_NAME, BFIN_SPORT_UART_MAX_PORTS, 0); 758 + 759 + register_console(&sport_uart_console); 760 + 761 + return 0; 762 + } 763 + console_initcall(sport_uart_rs_console_init); 764 + #endif 639 765 640 766 static int __init sport_uart_init(void) 641 767 { 642 768 int ret; 643 769 644 - pr_debug("%s enter\n", __func__); 770 + pr_info("Serial: Blackfin uart over sport driver\n"); 771 + 645 772 ret = uart_register_driver(&sport_uart_reg); 646 - if (ret != 0) { 647 - printk(KERN_ERR "Failed to register %s:%d\n", 773 + if (ret) { 774 + pr_err("failed to register %s:%d\n", 648 775 sport_uart_reg.driver_name, ret); 649 776 return ret; 650 777 } 651 778 652 779 ret = platform_driver_register(&sport_uart_driver); 653 - if (ret != 0) { 654 - printk(KERN_ERR "Failed to register sport uart driver:%d\n", ret); 780 + if (ret) { 781 + pr_err("failed to register sport uart driver:%d\n", ret); 655 782 uart_unregister_driver(&sport_uart_reg); 656 783 } 657 784 658 - 659 - pr_debug("%s exit\n", __func__); 660 785 return ret; 661 786 } 787 + module_init(sport_uart_init); 662 788 663 789 static void __exit sport_uart_exit(void) 664 790 { 665 - pr_debug("%s enter\n", __func__); 666 791 platform_driver_unregister(&sport_uart_driver); 667 792 uart_unregister_driver(&sport_uart_reg); 668 793 } 669 - 670 - module_init(sport_uart_init); 671 794 module_exit(sport_uart_exit); 672 795 796 + MODULE_AUTHOR("Sonic Zhang, Roy Huang"); 797 + MODULE_DESCRIPTION("Blackfin serial over SPORT driver"); 673 798 MODULE_LICENSE("GPL");
+18 -20
drivers/serial/bfin_sport_uart.h
··· 1 1 /* 2 - * File: linux/drivers/serial/bfin_sport_uart.h 2 + * Blackfin On-Chip Sport Emulated UART Driver 3 3 * 4 - * Based on: include/asm-blackfin/mach-533/bfin_serial_5xx.h 5 - * Author: Roy Huang <roy.huang>analog.com> 4 + * Copyright 2006-2008 Analog Devices Inc. 6 5 * 7 - * Created: Nov 22, 2006 8 - * Copyright: (C) Analog Device Inc. 9 - * Description: this driver enable SPORTs on Blackfin emulate UART. 6 + * Enter bugs at http://blackfin.uclinux.org/ 10 7 * 11 - * This program is free software; you can redistribute it and/or modify 12 - * it under the terms of the GNU General Public License as published by 13 - * the Free Software Foundation; either version 2 of the License, or 14 - * (at your option) any later version. 15 - * 16 - * This program is distributed in the hope that it will be useful, 17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 - * GNU General Public License for more details. 20 - * 21 - * You should have received a copy of the GNU General Public License 22 - * along with this program; if not, see the file COPYING, or write 23 - * to the Free Software Foundation, Inc., 24 - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 8 + * Licensed under the GPL-2 or later. 25 9 */ 26 10 11 + /* 12 + * This driver and the hardware supported are in term of EE-191 of ADI. 13 + * http://www.analog.com/UploadedFiles/Application_Notes/399447663EE191.pdf 14 + * This application note describe how to implement a UART on a Sharc DSP, 15 + * but this driver is implemented on Blackfin Processor. 16 + * Transmit Frame Sync is not used by this driver to transfer data out. 17 + */ 18 + 19 + #ifndef _BFIN_SPORT_UART_H 20 + #define _BFIN_SPORT_UART_H 27 21 28 22 #define OFFSET_TCR1 0x00 /* Transmit Configuration 1 Register */ 29 23 #define OFFSET_TCR2 0x04 /* Transmit Configuration 2 Register */ ··· 55 61 #define SPORT_PUT_RCLKDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RCLKDIV), v) 56 62 #define SPORT_PUT_RFSDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RFSDIV), v) 57 63 #define SPORT_PUT_STAT(sport, v) bfin_write16(((sport)->port.membase + OFFSET_STAT), v) 64 + 65 + #define SPORT_TX_FIFO_SIZE 8 66 + 67 + #endif /* _BFIN_SPORT_UART_H */
+3 -2
drivers/serial/icom.c
··· 751 751 trace(icom_port, "FID_STATUS", status); 752 752 count = cpu_to_le16(icom_port->statStg->rcv[rcv_buff].leLength); 753 753 754 - count = tty_buffer_request_room(tty, count); 755 754 trace(icom_port, "RCV_COUNT", count); 756 755 757 756 trace(icom_port, "REAL_COUNT", count); ··· 1653 1654 MODULE_SUPPORTED_DEVICE 1654 1655 ("IBM iSeries 2745, 2771, 2772, 2742, 2793 and 2805 Communications adapters"); 1655 1656 MODULE_LICENSE("GPL"); 1656 - 1657 + MODULE_FIRMWARE("icom_call_setup.bin"); 1658 + MODULE_FIRMWARE("icom_res_dce.bin"); 1659 + MODULE_FIRMWARE("icom_asc.bin");
+3 -3
drivers/serial/imx.c
··· 1279 1279 sport->use_irda = 1; 1280 1280 #endif 1281 1281 1282 - if (pdata->init) { 1282 + if (pdata && pdata->init) { 1283 1283 ret = pdata->init(pdev); 1284 1284 if (ret) 1285 1285 goto clkput; ··· 1292 1292 1293 1293 return 0; 1294 1294 deinit: 1295 - if (pdata->exit) 1295 + if (pdata && pdata->exit) 1296 1296 pdata->exit(pdev); 1297 1297 clkput: 1298 1298 clk_put(sport->clk); ··· 1321 1321 1322 1322 clk_disable(sport->clk); 1323 1323 1324 - if (pdata->exit) 1324 + if (pdata && pdata->exit) 1325 1325 pdata->exit(pdev); 1326 1326 1327 1327 iounmap(sport->port.membase);
+1 -2
drivers/serial/ioc3_serial.c
··· 1411 1411 read_count = do_read(the_port, ch, MAX_CHARS); 1412 1412 if (read_count > 0) { 1413 1413 flip = 1; 1414 - read_room = tty_buffer_request_room(tty, read_count); 1415 - tty_insert_flip_string(tty, ch, read_room); 1414 + read_room = tty_insert_flip_string(tty, ch, read_count); 1416 1415 the_port->icount.rx += read_count; 1417 1416 } 1418 1417 spin_unlock_irqrestore(&the_port->lock, pflags);
+1
drivers/serial/jsm/jsm_driver.c
··· 179 179 180 180 return 0; 181 181 out_free_irq: 182 + jsm_remove_uart_port(brd); 182 183 free_irq(brd->irq, brd); 183 184 out_iounmap: 184 185 iounmap(brd->re_map_membase);
+6 -3
drivers/serial/jsm/jsm_tty.c
··· 432 432 433 433 int jsm_uart_port_init(struct jsm_board *brd) 434 434 { 435 - int i; 435 + int i, rc; 436 436 unsigned int line; 437 437 struct jsm_channel *ch; 438 438 ··· 467 467 } else 468 468 set_bit(line, linemap); 469 469 brd->channels[i]->uart_port.line = line; 470 - if (uart_add_one_port (&jsm_uart_driver, &brd->channels[i]->uart_port)) 471 - printk(KERN_INFO "jsm: add device failed\n"); 470 + rc = uart_add_one_port (&jsm_uart_driver, &brd->channels[i]->uart_port); 471 + if (rc){ 472 + printk(KERN_INFO "jsm: Port %d failed. Aborting...\n", i); 473 + return rc; 474 + } 472 475 else 473 476 printk(KERN_INFO "jsm: Port %d added\n", i); 474 477 }
+4 -2
drivers/serial/msm_serial.c
··· 691 691 struct msm_port *msm_port; 692 692 struct resource *resource; 693 693 struct uart_port *port; 694 + int irq; 694 695 695 696 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR)) 696 697 return -ENXIO; ··· 712 711 return -ENXIO; 713 712 port->mapbase = resource->start; 714 713 715 - port->irq = platform_get_irq(pdev, 0); 716 - if (unlikely(port->irq < 0)) 714 + irq = platform_get_irq(pdev, 0); 715 + if (unlikely(irq < 0)) 717 716 return -ENXIO; 717 + port->irq = irq; 718 718 719 719 platform_set_drvdata(pdev, port); 720 720
+4 -3
drivers/serial/timbuart.c
··· 421 421 422 422 static int timbuart_probe(struct platform_device *dev) 423 423 { 424 - int err; 424 + int err, irq; 425 425 struct timbuart_port *uart; 426 426 struct resource *iomem; 427 427 ··· 453 453 uart->port.mapbase = iomem->start; 454 454 uart->port.membase = NULL; 455 455 456 - uart->port.irq = platform_get_irq(dev, 0); 457 - if (uart->port.irq < 0) { 456 + irq = platform_get_irq(dev, 0); 457 + if (irq < 0) { 458 458 err = -EINVAL; 459 459 goto err_register; 460 460 } 461 + uart->port.irq = irq; 461 462 462 463 tasklet_init(&uart->tasklet, timbuart_tasklet, (unsigned long)uart); 463 464
+7
drivers/usb/serial/keyspan_pda.c
··· 789 789 return 1; 790 790 } 791 791 792 + #ifdef KEYSPAN 793 + MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw"); 794 + #endif 795 + #ifdef XIRCOM 796 + MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); 797 + #endif 798 + 792 799 static int keyspan_pda_startup(struct usb_serial *serial) 793 800 { 794 801
+3
include/linux/pci_ids.h
··· 2332 2332 #define PCI_VENDOR_ID_KORENIX 0x1982 2333 2333 #define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600 2334 2334 #define PCI_DEVICE_ID_KORENIX_JETCARDF1 0x16ff 2335 + #define PCI_DEVICE_ID_KORENIX_JETCARDF2 0x1700 2336 + #define PCI_DEVICE_ID_KORENIX_JETCARDF3 0x17ff 2335 2337 2336 2338 #define PCI_VENDOR_ID_QMI 0x1a32 2337 2339 ··· 2698 2696 #define PCI_DEVICE_ID_NETMOS_9835 0x9835 2699 2697 #define PCI_DEVICE_ID_NETMOS_9845 0x9845 2700 2698 #define PCI_DEVICE_ID_NETMOS_9855 0x9855 2699 + #define PCI_DEVICE_ID_NETMOS_9865 0x9865 2701 2700 #define PCI_DEVICE_ID_NETMOS_9901 0x9901 2702 2701 2703 2702 #define PCI_VENDOR_ID_3COM_2 0xa727
+10
include/linux/tty.h
··· 68 68 unsigned long data[0]; 69 69 }; 70 70 71 + /* 72 + * We default to dicing tty buffer allocations to this many characters 73 + * in order to avoid multiple page allocations. We assume tty_buffer itself 74 + * is under 256 bytes. See tty_buffer_find for the allocation logic this 75 + * must match 76 + */ 77 + 78 + #define TTY_BUFFER_PAGE ((PAGE_SIZE - 256) / 2) 79 + 80 + 71 81 struct tty_bufhead { 72 82 struct delayed_work work; 73 83 spinlock_t lock;
+2 -1
include/linux/vt.h
··· 27 27 #define VT_SETMODE 0x5602 /* set mode of active vt */ 28 28 #define VT_AUTO 0x00 /* auto vt switching */ 29 29 #define VT_PROCESS 0x01 /* process controls switching */ 30 - #define VT_ACKACQ 0x02 /* acknowledge switch */ 30 + #define VT_PROCESS_AUTO 0x02 /* process is notified of switching */ 31 31 32 32 struct vt_stat { 33 33 unsigned short v_active; /* active vt */ ··· 38 38 #define VT_SENDSIG 0x5604 /* signal to send to bitmask of vts */ 39 39 40 40 #define VT_RELDISP 0x5605 /* release display */ 41 + #define VT_ACKACQ 0x02 /* acknowledge switch */ 41 42 42 43 #define VT_ACTIVATE 0x5606 /* make vt active */ 43 44 #define VT_WAITACTIVE 0x5607 /* wait for vt active */