8250_fsl.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <linux/serial_reg.h>
  2. #include <linux/serial_8250.h>
  3. #include "8250.h"
  4. /*
  5. * Freescale 16550 UART "driver", Copyright (C) 2011 Paul Gortmaker.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This isn't a full driver; it just provides an alternate IRQ
  12. * handler to deal with an errata. Everything else is just
  13. * using the bog standard 8250 support.
  14. *
  15. * We follow code flow of serial8250_default_handle_irq() but add
  16. * a check for a break and insert a dummy read on the Rx for the
  17. * immediately following IRQ event.
  18. *
  19. * We re-use the already existing "bug handling" lsr_saved_flags
  20. * field to carry the "what we just did" information from the one
  21. * IRQ event to the next one.
  22. */
  23. int fsl8250_handle_irq(struct uart_port *port)
  24. {
  25. unsigned char lsr, orig_lsr;
  26. unsigned long flags;
  27. unsigned int iir;
  28. struct uart_8250_port *up =
  29. container_of(port, struct uart_8250_port, port);
  30. spin_lock_irqsave(&up->port.lock, flags);
  31. iir = port->serial_in(port, UART_IIR);
  32. if (iir & UART_IIR_NO_INT) {
  33. spin_unlock_irqrestore(&up->port.lock, flags);
  34. return 0;
  35. }
  36. /* This is the WAR; if last event was BRK, then read and return */
  37. if (unlikely(up->lsr_saved_flags & UART_LSR_BI)) {
  38. up->lsr_saved_flags &= ~UART_LSR_BI;
  39. port->serial_in(port, UART_RX);
  40. spin_unlock_irqrestore(&up->port.lock, flags);
  41. return 1;
  42. }
  43. lsr = orig_lsr = up->port.serial_in(&up->port, UART_LSR);
  44. if (lsr & (UART_LSR_DR | UART_LSR_BI))
  45. lsr = serial8250_rx_chars(up, lsr);
  46. serial8250_modem_status(up);
  47. if (lsr & UART_LSR_THRE)
  48. serial8250_tx_chars(up);
  49. up->lsr_saved_flags = orig_lsr;
  50. spin_unlock_irqrestore(&up->port.lock, flags);
  51. return 1;
  52. }