blob: 4cc9139398171f8324698a205245e213e4a9b37c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Woodhousef2999e42006-04-25 14:07:02 +010015#ifdef __KERNEL__
Ingo Molnar81861d72006-03-23 03:00:44 -080016#include <linux/mutex.h>
Alan Coxb5391e22008-07-16 21:55:20 +010017#include <linux/tty.h>
Ingo Molnar81861d72006-03-23 03:00:44 -080018
Linus Torvalds1da177e2005-04-16 15:20:36 -070019struct 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 *);
24 int (*get_CD) (void *);
25 void (*shutdown_port) (void*);
26 int (*set_real_termios) (void*);
27 int (*chars_in_buffer) (void*);
28 void (*close) (void*);
29 void (*hungup) (void*);
30 void (*getserial) (void*, struct serial_struct *sp);
31};
32
33
34
35struct gs_port {
36 int magic;
Alan Coxb5391e22008-07-16 21:55:20 +010037 struct tty_port port;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 unsigned char *xmit_buf;
39 int xmit_head;
40 int xmit_tail;
41 int xmit_cnt;
Ingo Molnar81861d72006-03-23 03:00:44 -080042 struct mutex port_write_mutex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 unsigned long event;
44 unsigned short closing_wait;
45 int close_delay;
46 struct real_driver *rd;
47 int wakeup_chars;
48 int baud_base;
49 int baud;
50 int custom_divisor;
51 spinlock_t driver_lock;
52};
53
David Woodhousef2999e42006-04-25 14:07:02 +010054#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56/* Flags */
57/* Warning: serial.h defines some ASYNC_ flags, they say they are "only"
58 used in serial.c, but they are also used in all other serial drivers.
59 Make sure they don't clash with these here... */
60#define GS_TX_INTEN 0x00800000
61#define GS_RX_INTEN 0x00400000
62#define GS_ACTIVE 0x00200000
63
64
65
66#define GS_TYPE_NORMAL 1
67
68#define GS_DEBUG_FLUSH 0x00000001
69#define GS_DEBUG_BTR 0x00000002
70#define GS_DEBUG_TERMIOS 0x00000004
71#define GS_DEBUG_STUFF 0x00000008
72#define GS_DEBUG_CLOSE 0x00000010
73#define GS_DEBUG_FLOW 0x00000020
74#define GS_DEBUG_WRITE 0x00000040
75
David Woodhousef2999e42006-04-25 14:07:02 +010076#ifdef __KERNEL__
Alan Cox76b25a52008-04-30 00:54:03 -070077int gs_put_char(struct tty_struct *tty, unsigned char ch);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078int gs_write(struct tty_struct *tty,
79 const unsigned char *buf, int count);
80int gs_write_room(struct tty_struct *tty);
81int gs_chars_in_buffer(struct tty_struct *tty);
82void gs_flush_buffer(struct tty_struct *tty);
83void gs_flush_chars(struct tty_struct *tty);
84void gs_stop(struct tty_struct *tty);
85void gs_start(struct tty_struct *tty);
86void gs_hangup(struct tty_struct *tty);
87int gs_block_til_ready(void *port, struct file *filp);
88void gs_close(struct tty_struct *tty, struct file *filp);
89void gs_set_termios (struct tty_struct * tty,
Alan Cox606d0992006-12-08 02:38:45 -080090 struct ktermios * old_termios);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091int gs_init_port(struct gs_port *port);
92int gs_setserial(struct gs_port *port, struct serial_struct __user *sp);
93int gs_getserial(struct gs_port *port, struct serial_struct __user *sp);
94void gs_got_break(struct gs_port *port);
David Woodhousef2999e42006-04-25 14:07:02 +010095#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#endif