summaryrefslogtreecommitdiffstats
path: root/include/linux/scc.h
blob: 1ec4417461ae046df4d2295b9da3e1bb9c99b0cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* $Id: scc.h,v 1.29 1997/04/02 14:56:45 jreuter Exp jreuter $ */

#ifndef	_SCC_H
#define	_SCC_H

#include <linux/config.h>

/* selection of hardware types */

#define PA0HZP		0x00	/* hardware type for PA0HZP SCC card and compatible */
#define EAGLE         	0x01    /* hardware type for EAGLE card */
#define PC100		0x02	/* hardware type for PC100 card */
#define PRIMUS		0x04	/* hardware type for PRIMUS-PC (DG9BL) card */
#define DRSI		0x08	/* hardware type for DRSI PC*Packet card */
#define BAYCOM		0x10	/* hardware type for BayCom (U)SCC */

/* DEV ioctl() commands */

enum SCC_ioctl_cmds {
	SIOCSCCRESERVED = SIOCDEVPRIVATE,
	SIOCSCCCFG,
	SIOCSCCINI,
	SIOCSCCCHANINI,
	SIOCSCCSMEM,
	SIOCSCCGMODEM,
	SIOCSCCSMODEM,
	SIOCSCCGSTAT,
	SIOCSCCCAL
};

/* magic number */

#define SCC_MAGIC	0x8530		/* ;-) */

/* misc. parameters */

#define TIMER_OFF	65535U	/* to switch off timers */

/* Tx/Rx clock sources */

typedef enum {
	CLOCK_SOURCE_RTxC,	/* use RTxC pin */
	CLOCK_SOURCE_TRxC,	/* use TRxC pin */
	CLOCK_SOURCE_BRG,	/* use baud rate generator */
	CLOCK_SOURCE_DPLL	/* use DPLL */
} Scc_clock_sources;

typedef enum {
	TRXCP_MODE_IN,		/* TRxC pin is input */
	TRXCP_MODE_TXC_OUT,	/* TRxC bears Tx clock */
	TRXCP_MODE_BRG_OUT,	/* TRxC bears BRG output */
	TRXCP_MODE_DPLL_OUT	/* TRxC bears DPLL */

} Scc_trxc_pin_modes;

/* Tx state */

typedef enum {
	TXS_IDLE,	/* Transmitter off, no data pending */
	TXS_TXDELAY,	/* waiting for transmitter keyed up */
	TXS_ACTIVE,	/* Transmitter on, sending data */
	TXS_TAIL,	/* Transmition tail time */
} Scc_tx_states;

typedef unsigned long io_port;	/* type definition for an 'io port address' */

/* SCC statistical information */

struct scc_stat {
        long rxints;            /* Receiver interrupts */
        long txints;            /* Transmitter interrupts */
        long exints;            /* External/status interrupts */
        long spints;            /* Special receiver interrupts */

        long txframes;          /* Packets sent */
        long rxframes;          /* Number of Frames Actually Received */
        long rxerrs;            /* CRC Errors */
        long txerrs;		/* KISS errors */
        
	unsigned int nospace;	/* "Out of buffers" */
	unsigned int rx_over;	/* Receiver Overruns */
	unsigned int tx_under;	/* Transmitter Underruns */

	unsigned int tx_state;	/* Transmitter state */
	unsigned int bufsize;	/* used buffersize */
};

struct scc_modem {
	int	rx_speed;		/* Line speed, bps */
	int	tx_speed;
	int	rx_clock_source;	/* see CLOCK_sources above */
	int	tx_clock_source;	/* dito */
	int	trxc_pin_mode;		/* see TRXCP_modes above */
	int	nrz_mode;		/* 0 = NRZ, 1 = NRZI */
	int	tx_delay;		/* tx delay in msec */
	int	tx_tail;		/* tx tail time in msec */
	int	fullduplex;		/* Duplex mode: 0 = "halfduplex", 1 = "fullduplex" */
	int	trx_feedback;		/* TRX feeds transmit signal back to RxD */
	int	tx_inhibit;		/* Transmit is not allowed when set */
	int	softdcd;		/* Use DPLL instead of DCD pin for carrier detect */
};

#ifdef __KERNEL__

enum {TX_OFF, TX_ON};	/* command for scc_key_trx() */

/* Vector masks in RR2B */

#define VECTOR_MASK	0x06
#define TXINT		0x00
#define EXINT		0x02
#define RXINT		0x04
#define SPINT		0x06

/* SCC channel structure */

struct scc_channel {
	int init;			/* channel exists? */

	struct net_device *dev;		/* link to device control structure */
	struct net_device_stats dev_stat;/* device statistics */
	struct ax25_dev ax25dev;
	char * proc_dev_name;		/* points to dev->name or NULL */

	char brand;			/* manufacturer of the board */
	long clock;			/* used clock */

	io_port ctrl;			/* I/O address of CONTROL register */
	io_port	data;			/* I/O address of DATA register */
	io_port special_port;		/* I/O address of special function port */
	int irq;			/* Number of Interrupt */

	char special_option;
	char enhanced;			/* Enhanced SCC support */

	unsigned char wreg[16]; 	/* Copy of last written value in WRx */
	unsigned char status;		/* Copy of R0 at last external interrupt */
	unsigned char dcd;		/* DCD status */

        struct scc_modem modem; 	/* modem information */
        struct scc_stat  stat;		/* statistical information */

        struct {
		spinlock_t hwaccess;	/* hardware access */
		spinlock_t timer;	/* timer functions */
		spinlock_t kick_tx;	/* start of transmission */
        } spinlocks;

        struct {
		ctl_table  channel[6];	/* /.../chip_<n>/channel_<k>/ */
		ctl_table  modem[13];	/* /.../channel_<k>/modem/ */
		ctl_table  stats[1];	/* /.../channel_<k>/stats/ */
        } proc_tables;


        struct sk_buff *rx_buff;	/* pointer to frame currently received */
        struct sk_buff *tx_buff;	/* pointer to frame currently transmitted */
        struct sk_buff *tx_new;		/* next transmit buffer */
        struct timer_list tx_timer;	/* Tx delay & tail timer */
};

int scc_init(void);
#endif /* defined(__KERNEL__) */
#endif /* defined(_SCC_H) */