0001
0002
0003
0004
0005
0006
0007 #ifndef _LINUX_SERIAL_8250_H
0008 #define _LINUX_SERIAL_8250_H
0009
0010 #include <linux/serial_core.h>
0011 #include <linux/serial_reg.h>
0012 #include <linux/platform_device.h>
0013
0014
0015
0016
0017 struct plat_serial8250_port {
0018 unsigned long iobase;
0019 void __iomem *membase;
0020 resource_size_t mapbase;
0021 unsigned int irq;
0022 unsigned long irqflags;
0023 unsigned int uartclk;
0024 void *private_data;
0025 unsigned char regshift;
0026 unsigned char iotype;
0027 unsigned char hub6;
0028 unsigned char has_sysrq;
0029 upf_t flags;
0030 unsigned int type;
0031 unsigned int (*serial_in)(struct uart_port *, int);
0032 void (*serial_out)(struct uart_port *, int, int);
0033 void (*set_termios)(struct uart_port *,
0034 struct ktermios *new,
0035 struct ktermios *old);
0036 void (*set_ldisc)(struct uart_port *,
0037 struct ktermios *);
0038 unsigned int (*get_mctrl)(struct uart_port *);
0039 int (*handle_irq)(struct uart_port *);
0040 void (*pm)(struct uart_port *, unsigned int state,
0041 unsigned old);
0042 void (*handle_break)(struct uart_port *);
0043 };
0044
0045
0046
0047
0048
0049 enum {
0050 PLAT8250_DEV_LEGACY = -1,
0051 PLAT8250_DEV_PLATFORM,
0052 PLAT8250_DEV_PLATFORM1,
0053 PLAT8250_DEV_PLATFORM2,
0054 PLAT8250_DEV_FOURPORT,
0055 PLAT8250_DEV_ACCENT,
0056 PLAT8250_DEV_BOCA,
0057 PLAT8250_DEV_EXAR_ST16C554,
0058 PLAT8250_DEV_HUB6,
0059 PLAT8250_DEV_AU1X00,
0060 PLAT8250_DEV_SM501,
0061 };
0062
0063 struct uart_8250_dma;
0064 struct uart_8250_port;
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074 struct uart_8250_ops {
0075 int (*setup_irq)(struct uart_8250_port *);
0076 void (*release_irq)(struct uart_8250_port *);
0077 };
0078
0079 struct uart_8250_em485 {
0080 struct hrtimer start_tx_timer;
0081 struct hrtimer stop_tx_timer;
0082 struct hrtimer *active_timer;
0083 struct uart_8250_port *port;
0084 unsigned int tx_stopped:1;
0085 };
0086
0087
0088
0089
0090
0091
0092
0093
0094 struct uart_8250_port {
0095 struct uart_port port;
0096 struct timer_list timer;
0097 struct list_head list;
0098 u32 capabilities;
0099 unsigned short bugs;
0100 bool fifo_bug;
0101 unsigned int tx_loadsz;
0102 unsigned char acr;
0103 unsigned char fcr;
0104 unsigned char ier;
0105 unsigned char lcr;
0106 unsigned char mcr;
0107 unsigned char cur_iotype;
0108 unsigned int rpm_tx_active;
0109 unsigned char canary;
0110
0111
0112 unsigned char probe;
0113 struct mctrl_gpios *gpios;
0114 #define UART_PROBE_RSA (1 << 0)
0115
0116
0117
0118
0119
0120
0121 #define LSR_SAVE_FLAGS UART_LSR_BRK_ERROR_BITS
0122 u16 lsr_saved_flags;
0123 u16 lsr_save_mask;
0124 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
0125 unsigned char msr_saved_flags;
0126
0127 struct uart_8250_dma *dma;
0128 const struct uart_8250_ops *ops;
0129
0130
0131 int (*dl_read)(struct uart_8250_port *);
0132 void (*dl_write)(struct uart_8250_port *, int);
0133
0134 struct uart_8250_em485 *em485;
0135 void (*rs485_start_tx)(struct uart_8250_port *);
0136 void (*rs485_stop_tx)(struct uart_8250_port *);
0137
0138
0139 struct delayed_work overrun_backoff;
0140 u32 overrun_backoff_time_ms;
0141 };
0142
0143 static inline struct uart_8250_port *up_to_u8250p(struct uart_port *up)
0144 {
0145 return container_of(up, struct uart_8250_port, port);
0146 }
0147
0148 int serial8250_register_8250_port(const struct uart_8250_port *);
0149 void serial8250_unregister_port(int line);
0150 void serial8250_suspend_port(int line);
0151 void serial8250_resume_port(int line);
0152
0153 extern int early_serial_setup(struct uart_port *port);
0154
0155 extern int early_serial8250_setup(struct earlycon_device *device,
0156 const char *options);
0157 extern void serial8250_update_uartclk(struct uart_port *port,
0158 unsigned int uartclk);
0159 extern void serial8250_do_set_termios(struct uart_port *port,
0160 struct ktermios *termios, struct ktermios *old);
0161 extern void serial8250_do_set_ldisc(struct uart_port *port,
0162 struct ktermios *termios);
0163 extern unsigned int serial8250_do_get_mctrl(struct uart_port *port);
0164 extern int serial8250_do_startup(struct uart_port *port);
0165 extern void serial8250_do_shutdown(struct uart_port *port);
0166 extern void serial8250_do_pm(struct uart_port *port, unsigned int state,
0167 unsigned int oldstate);
0168 extern void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl);
0169 extern void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
0170 unsigned int quot,
0171 unsigned int quot_frac);
0172 extern int fsl8250_handle_irq(struct uart_port *port);
0173 int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
0174 u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr);
0175 void serial8250_read_char(struct uart_8250_port *up, u16 lsr);
0176 void serial8250_tx_chars(struct uart_8250_port *up);
0177 unsigned int serial8250_modem_status(struct uart_8250_port *up);
0178 void serial8250_init_port(struct uart_8250_port *up);
0179 void serial8250_set_defaults(struct uart_8250_port *up);
0180 void serial8250_console_write(struct uart_8250_port *up, const char *s,
0181 unsigned int count);
0182 int serial8250_console_setup(struct uart_port *port, char *options, bool probe);
0183 int serial8250_console_exit(struct uart_port *port);
0184
0185 extern void serial8250_set_isa_configurator(void (*v)
0186 (int port, struct uart_port *up,
0187 u32 *capabilities));
0188
0189 #ifdef CONFIG_SERIAL_8250_RT288X
0190 unsigned int au_serial_in(struct uart_port *p, int offset);
0191 void au_serial_out(struct uart_port *p, int offset, int value);
0192 #endif
0193
0194 #endif