Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * generic_serial.h |
| 3 | * |
| 4 | * Copyright (C) 1998 R.E.Wolff@BitWizard.nl |
| 5 | * |
| 6 | * written for the SX serial driver. |
| 7 | * Contains the code that should be shared over all the serial drivers. |
| 8 | * |
| 9 | * Version 0.1 -- December, 1998. |
| 10 | */ |
| 11 | |
| 12 | #ifndef GENERIC_SERIAL_H |
| 13 | #define GENERIC_SERIAL_H |
| 14 | |
David Woodhouse | f2999e4 | 2006-04-25 14:07:02 +0100 | [diff] [blame] | 15 | #ifdef __KERNEL__ |
Ingo Molnar | 81861d7 | 2006-03-23 03:00:44 -0800 | [diff] [blame] | 16 | #include <linux/mutex.h> |
Alan Cox | b5391e2 | 2008-07-16 21:55:20 +0100 | [diff] [blame] | 17 | #include <linux/tty.h> |
Ingo Molnar | 81861d7 | 2006-03-23 03:00:44 -0800 | [diff] [blame] | 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | struct real_driver { |
| 20 | void (*disable_tx_interrupts) (void *); |
| 21 | void (*enable_tx_interrupts) (void *); |
| 22 | void (*disable_rx_interrupts) (void *); |
| 23 | void (*enable_rx_interrupts) (void *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | void (*shutdown_port) (void*); |
| 25 | int (*set_real_termios) (void*); |
| 26 | int (*chars_in_buffer) (void*); |
| 27 | void (*close) (void*); |
| 28 | void (*hungup) (void*); |
| 29 | void (*getserial) (void*, struct serial_struct *sp); |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | |
| 34 | struct gs_port { |
| 35 | int magic; |
Alan Cox | b5391e2 | 2008-07-16 21:55:20 +0100 | [diff] [blame] | 36 | struct tty_port port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | unsigned char *xmit_buf; |
| 38 | int xmit_head; |
| 39 | int xmit_tail; |
| 40 | int xmit_cnt; |
Ingo Molnar | 81861d7 | 2006-03-23 03:00:44 -0800 | [diff] [blame] | 41 | struct mutex port_write_mutex; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | unsigned long event; |
| 43 | unsigned short closing_wait; |
| 44 | int close_delay; |
| 45 | struct real_driver *rd; |
| 46 | int wakeup_chars; |
| 47 | int baud_base; |
| 48 | int baud; |
| 49 | int custom_divisor; |
| 50 | spinlock_t driver_lock; |
| 51 | }; |
| 52 | |
David Woodhouse | f2999e4 | 2006-04-25 14:07:02 +0100 | [diff] [blame] | 53 | #endif /* __KERNEL__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /* Flags */ |
| 56 | /* Warning: serial.h defines some ASYNC_ flags, they say they are "only" |
| 57 | used in serial.c, but they are also used in all other serial drivers. |
| 58 | Make sure they don't clash with these here... */ |
| 59 | #define GS_TX_INTEN 0x00800000 |
| 60 | #define GS_RX_INTEN 0x00400000 |
| 61 | #define GS_ACTIVE 0x00200000 |
| 62 | |
| 63 | |
| 64 | |
| 65 | #define GS_TYPE_NORMAL 1 |
| 66 | |
| 67 | #define GS_DEBUG_FLUSH 0x00000001 |
| 68 | #define GS_DEBUG_BTR 0x00000002 |
| 69 | #define GS_DEBUG_TERMIOS 0x00000004 |
| 70 | #define GS_DEBUG_STUFF 0x00000008 |
| 71 | #define GS_DEBUG_CLOSE 0x00000010 |
| 72 | #define GS_DEBUG_FLOW 0x00000020 |
| 73 | #define GS_DEBUG_WRITE 0x00000040 |
| 74 | |
David Woodhouse | f2999e4 | 2006-04-25 14:07:02 +0100 | [diff] [blame] | 75 | #ifdef __KERNEL__ |
Alan Cox | 76b25a5 | 2008-04-30 00:54:03 -0700 | [diff] [blame] | 76 | int gs_put_char(struct tty_struct *tty, unsigned char ch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | int gs_write(struct tty_struct *tty, |
| 78 | const unsigned char *buf, int count); |
| 79 | int gs_write_room(struct tty_struct *tty); |
| 80 | int gs_chars_in_buffer(struct tty_struct *tty); |
| 81 | void gs_flush_buffer(struct tty_struct *tty); |
| 82 | void gs_flush_chars(struct tty_struct *tty); |
| 83 | void gs_stop(struct tty_struct *tty); |
| 84 | void gs_start(struct tty_struct *tty); |
| 85 | void gs_hangup(struct tty_struct *tty); |
| 86 | int gs_block_til_ready(void *port, struct file *filp); |
| 87 | void gs_close(struct tty_struct *tty, struct file *filp); |
| 88 | void gs_set_termios (struct tty_struct * tty, |
Alan Cox | 606d099 | 2006-12-08 02:38:45 -0800 | [diff] [blame] | 89 | struct ktermios * old_termios); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | int gs_init_port(struct gs_port *port); |
| 91 | int gs_setserial(struct gs_port *port, struct serial_struct __user *sp); |
| 92 | int gs_getserial(struct gs_port *port, struct serial_struct __user *sp); |
| 93 | void gs_got_break(struct gs_port *port); |
David Woodhouse | f2999e4 | 2006-04-25 14:07:02 +0100 | [diff] [blame] | 94 | #endif /* __KERNEL__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | #endif |