serial_8250.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. void (*set_ldisc)(struct uart_port *,
  38. struct ktermios *);
  39. unsigned int (*get_mctrl)(struct uart_port *);
  40. int (*handle_irq)(struct uart_port *);
  41. void (*pm)(struct uart_port *, unsigned int state,
  42. unsigned old);
  43. void (*handle_break)(struct uart_port *);
  44. };
  45. /*
  46. * Allocate 8250 platform device IDs. Nothing is implied by
  47. * the numbering here, except for the legacy entry being -1.
  48. */
  49. enum {
  50. PLAT8250_DEV_LEGACY = -1,
  51. PLAT8250_DEV_PLATFORM,
  52. PLAT8250_DEV_PLATFORM1,
  53. PLAT8250_DEV_PLATFORM2,
  54. PLAT8250_DEV_FOURPORT,
  55. PLAT8250_DEV_ACCENT,
  56. PLAT8250_DEV_BOCA,
  57. PLAT8250_DEV_EXAR_ST16C554,
  58. PLAT8250_DEV_HUB6,
  59. PLAT8250_DEV_AU1X00,
  60. PLAT8250_DEV_SM501,
  61. };
  62. struct uart_8250_dma;
  63. struct uart_8250_port;
  64. /**
  65. * 8250 core driver operations
  66. *
  67. * @setup_irq() Setup irq handling. The universal 8250 driver links this
  68. * port to the irq chain. Other drivers may @request_irq().
  69. * @release_irq() Undo irq handling. The universal 8250 driver unlinks
  70. * the port from the irq chain.
  71. */
  72. struct uart_8250_ops {
  73. int (*setup_irq)(struct uart_8250_port *);
  74. void (*release_irq)(struct uart_8250_port *);
  75. };
  76. struct uart_8250_em485 {
  77. struct hrtimer start_tx_timer; /* "rs485 start tx" timer */
  78. struct hrtimer stop_tx_timer; /* "rs485 stop tx" timer */
  79. struct hrtimer *active_timer; /* pointer to active timer */
  80. struct uart_8250_port *port; /* for hrtimer callbacks */
  81. };
  82. /*
  83. * This should be used by drivers which want to register
  84. * their own 8250 ports without registering their own
  85. * platform device. Using these will make your driver
  86. * dependent on the 8250 driver.
  87. */
  88. struct uart_8250_port {
  89. struct uart_port port;
  90. struct timer_list timer; /* "no irq" timer */
  91. struct list_head list; /* ports on this IRQ */
  92. u32 capabilities; /* port capabilities */
  93. unsigned short bugs; /* port bugs */
  94. bool fifo_bug; /* min RX trigger if enabled */
  95. unsigned int tx_loadsz; /* transmit fifo load size */
  96. unsigned char acr;
  97. unsigned char fcr;
  98. unsigned char ier;
  99. unsigned char lcr;
  100. unsigned char mcr;
  101. unsigned char mcr_mask; /* mask of user bits */
  102. unsigned char mcr_force; /* mask of forced bits */
  103. unsigned char cur_iotype; /* Running I/O type */
  104. unsigned int rpm_tx_active;
  105. unsigned char canary; /* non-zero during system sleep
  106. * if no_console_suspend
  107. */
  108. unsigned char probe;
  109. #define UART_PROBE_RSA (1 << 0)
  110. /*
  111. * Some bits in registers are cleared on a read, so they must
  112. * be saved whenever the register is read but the bits will not
  113. * be immediately processed.
  114. */
  115. #define LSR_SAVE_FLAGS UART_LSR_BRK_ERROR_BITS
  116. unsigned char lsr_saved_flags;
  117. #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
  118. unsigned char msr_saved_flags;
  119. struct uart_8250_dma *dma;
  120. const struct uart_8250_ops *ops;
  121. /* 8250 specific callbacks */
  122. int (*dl_read)(struct uart_8250_port *);
  123. void (*dl_write)(struct uart_8250_port *, int);
  124. struct uart_8250_em485 *em485;
  125. };
  126. static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
  127. {
  128. return container_of(up, struct uart_8250_port, port);
  129. }
  130. int serial8250_register_8250_port(struct uart_8250_port *);
  131. void serial8250_unregister_port(int line);
  132. void serial8250_suspend_port(int line);
  133. void serial8250_resume_port(int line);
  134. extern int early_serial_setup(struct uart_port *port);
  135. extern int early_serial8250_setup(struct earlycon_device *device,
  136. const char *options);
  137. extern void serial8250_do_set_termios(struct uart_port *port,
  138. struct ktermios *termios, struct ktermios *old);
  139. extern void serial8250_do_set_ldisc(struct uart_port *port,
  140. struct ktermios *termios);
  141. extern unsigned int serial8250_do_get_mctrl(struct uart_port *port);
  142. extern int serial8250_do_startup(struct uart_port *port);
  143. extern void serial8250_do_shutdown(struct uart_port *port);
  144. extern void serial8250_do_pm(struct uart_port *port, unsigned int state,
  145. unsigned int oldstate);
  146. extern void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
  147. extern void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
  148. unsigned int quot,
  149. unsigned int quot_frac);
  150. extern int fsl8250_handle_irq(struct uart_port *port);
  151. int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
  152. unsigned char serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr);
  153. void serial8250_read_char(struct uart_8250_port *up, unsigned char lsr);
  154. void serial8250_tx_chars(struct uart_8250_port *up);
  155. unsigned int serial8250_modem_status(struct uart_8250_port *up);
  156. void serial8250_init_port(struct uart_8250_port *up);
  157. void serial8250_set_defaults(struct uart_8250_port *up);
  158. void serial8250_console_write(struct uart_8250_port *up, const char *s,
  159. unsigned int count);
  160. int serial8250_console_setup(struct uart_port *port, char *options, bool probe);
  161. extern void serial8250_set_isa_configurator(void (*v)
  162. (int port, struct uart_port *up,
  163. u32 *capabilities));
  164. #endif