serial_8250.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * linux/include/linux/serial_8250.h
  3. *
  4. * Copyright (C) 2004 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef _LINUX_SERIAL_8250_H
  12. #define _LINUX_SERIAL_8250_H
  13. #include <linux/serial_core.h>
  14. #include <linux/serial_reg.h>
  15. #include <linux/platform_device.h>
  16. /*
  17. * This is the platform device platform_data structure
  18. */
  19. struct plat_serial8250_port {
  20. unsigned long iobase; /* io base address */
  21. void __iomem *membase; /* ioremap cookie or NULL */
  22. resource_size_t mapbase; /* resource base */
  23. unsigned int irq; /* interrupt number */
  24. unsigned long irqflags; /* request_irq flags */
  25. unsigned int uartclk; /* UART clock rate */
  26. void *private_data;
  27. unsigned char regshift; /* register shift */
  28. unsigned char iotype; /* UPIO_* */
  29. unsigned char hub6;
  30. upf_t flags; /* UPF_* flags */
  31. unsigned int type; /* If UPF_FIXED_TYPE */
  32. unsigned int (*serial_in)(struct uart_port *, int);
  33. void (*serial_out)(struct uart_port *, int, int);
  34. void (*set_termios)(struct uart_port *,
  35. struct ktermios *new,
  36. struct ktermios *old);
  37. unsigned int (*get_mctrl)(struct uart_port *);
  38. int (*handle_irq)(struct uart_port *);
  39. void (*pm)(struct uart_port *, unsigned int state,
  40. unsigned old);
  41. void (*handle_break)(struct uart_port *);
  42. };
  43. /*
  44. * Allocate 8250 platform device IDs. Nothing is implied by
  45. * the numbering here, except for the legacy entry being -1.
  46. */
  47. enum {
  48. PLAT8250_DEV_LEGACY = -1,
  49. PLAT8250_DEV_PLATFORM,
  50. PLAT8250_DEV_PLATFORM1,
  51. PLAT8250_DEV_PLATFORM2,
  52. PLAT8250_DEV_FOURPORT,
  53. PLAT8250_DEV_ACCENT,
  54. PLAT8250_DEV_BOCA,
  55. PLAT8250_DEV_EXAR_ST16C554,
  56. PLAT8250_DEV_HUB6,
  57. PLAT8250_DEV_AU1X00,
  58. PLAT8250_DEV_SM501,
  59. };
  60. struct uart_8250_dma;
  61. struct uart_8250_port;
  62. /**
  63. * 8250 core driver operations
  64. *
  65. * @setup_irq() Setup irq handling. The universal 8250 driver links this
  66. * port to the irq chain. Other drivers may @request_irq().
  67. * @release_irq() Undo irq handling. The universal 8250 driver unlinks
  68. * the port from the irq chain.
  69. */
  70. struct uart_8250_ops {
  71. int (*setup_irq)(struct uart_8250_port *);
  72. void (*release_irq)(struct uart_8250_port *);
  73. };
  74. struct uart_8250_em485 {
  75. struct timer_list start_tx_timer; /* "rs485 start tx" timer */
  76. struct timer_list stop_tx_timer; /* "rs485 stop tx" timer */
  77. struct timer_list *active_timer; /* pointer to active timer */
  78. };
  79. /*
  80. * This should be used by drivers which want to register
  81. * their own 8250 ports without registering their own
  82. * platform device. Using these will make your driver
  83. * dependent on the 8250 driver.
  84. */
  85. struct uart_8250_port {
  86. struct uart_port port;
  87. struct timer_list timer; /* "no irq" timer */
  88. struct list_head list; /* ports on this IRQ */
  89. unsigned short capabilities; /* port capabilities */
  90. unsigned short bugs; /* port bugs */
  91. bool fifo_bug; /* min RX trigger if enabled */
  92. unsigned int tx_loadsz; /* transmit fifo load size */
  93. unsigned char acr;
  94. unsigned char fcr;
  95. unsigned char ier;
  96. unsigned char lcr;
  97. unsigned char mcr;
  98. unsigned char mcr_mask; /* mask of user bits */
  99. unsigned char mcr_force; /* mask of forced bits */
  100. unsigned char cur_iotype; /* Running I/O type */
  101. unsigned int rpm_tx_active;
  102. unsigned char canary; /* non-zero during system sleep
  103. * if no_console_suspend
  104. */
  105. unsigned char probe;
  106. #define UART_PROBE_RSA (1 << 0)
  107. /*
  108. * Some bits in registers are cleared on a read, so they must
  109. * be saved whenever the register is read but the bits will not
  110. * be immediately processed.
  111. */
  112. #define LSR_SAVE_FLAGS UART_LSR_BRK_ERROR_BITS
  113. unsigned char lsr_saved_flags;
  114. #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
  115. unsigned char msr_saved_flags;
  116. struct uart_8250_dma *dma;
  117. const struct uart_8250_ops *ops;
  118. /* 8250 specific callbacks */
  119. int (*dl_read)(struct uart_8250_port *);
  120. void (*dl_write)(struct uart_8250_port *, int);
  121. struct uart_8250_em485 *em485;
  122. };
  123. static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
  124. {
  125. return container_of(up, struct uart_8250_port, port);
  126. }
  127. int serial8250_register_8250_port(struct uart_8250_port *);
  128. void serial8250_unregister_port(int line);
  129. void serial8250_suspend_port(int line);
  130. void serial8250_resume_port(int line);
  131. extern int early_serial_setup(struct uart_port *port);
  132. extern int early_serial8250_setup(struct earlycon_device *device,
  133. const char *options);
  134. extern void serial8250_do_set_termios(struct uart_port *port,
  135. struct ktermios *termios, struct ktermios *old);
  136. extern unsigned int serial8250_do_get_mctrl(struct uart_port *port);
  137. extern int serial8250_do_startup(struct uart_port *port);
  138. extern void serial8250_do_shutdown(struct uart_port *port);
  139. extern void serial8250_do_pm(struct uart_port *port, unsigned int state,
  140. unsigned int oldstate);
  141. extern void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
  142. extern int fsl8250_handle_irq(struct uart_port *port);
  143. int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
  144. unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr);
  145. void serial8250_tx_chars(struct uart_8250_port *up);
  146. unsigned int serial8250_modem_status(struct uart_8250_port *up);
  147. void serial8250_init_port(struct uart_8250_port *up);
  148. void serial8250_set_defaults(struct uart_8250_port *up);
  149. void serial8250_console_write(struct uart_8250_port *up, const char *s,
  150. unsigned int count);
  151. int serial8250_console_setup(struct uart_port *port, char *options, bool probe);
  152. extern void serial8250_set_isa_configurator(void (*v)
  153. (int port, struct uart_port *up,
  154. unsigned short *capabilities));
  155. #endif