/*
 * Copyright (C) 2000 Kees Cook
 * cook@cpoint.net, http://outflux.net/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 * http://www.gnu.org/copyleft/gpl.html
 *
 */
#ifndef FAS_H
#define FAS_H

/* FAS defines */
#define FAS_PKT_MAX     2048 /* Current size of FAS packet stream */
#if 0
#define FAS_SEND_MAX	(FAS_PKT_MAX - FAS_CMD_LEN - 1) /* max FAS_SEND data */
#else
#define FAS_SEND_MAX	500 /* about all it can handle *//*max FAS_SEND data */
#endif


#define FAS_CMD_LEN     8    /* bytes in a FAS_CMD header */

#define FAS_GLOBAL      0x00 /* Sets global firmware options for all lines */
#define FAS_ENABLE      0x01 /* Enables specific async line,
                                initializing to defaults; must be
                                issued before any other command to a line */
#define FAS_DISABLE     0x02 /* Disables specific async line, turning
                                off interrupts, etc. */
#define FAS_SEND        0x03 /* Sends data for output */
#define FAS_RECV        0x04 /* Receives input data */
#define FAS_IN_TIMERS   0x05 /* Sets custom block transfer parameters */
#define FAS_OUTPUT_CTL  0x06 /* Flushes, suspends, or resumes output at
                                a line */
#define FAS_INPUT_CTL   0x07 /* Flushes, suspends, or resumes input at
                                a line */
#define FAS_SET_MODEM   0x08 /* Controls modem output signals */
#define FAS_STAT_CHG    0x09 /* Monitors modem input signals */
#define FAS_SEND_BRK    0x0A /* Issues break indication */
#define FAS_SET_PARAMS  0x0B /* Sets line parameters (e.g., baud rate,
                                bits per character, stop bits) */
#define FAS_FLOW_CTL    0x0C /* Sets firmware flow control parameters */
#define FAS_RESERVE     0x0D /* Requests private use of a line */
#define FAS_RELEASE     0x0E /* Releases private use of a line */
#define FAS_CMD_MAX     FAS_RELEASE /* last opcode = size of command list */

#define PKT_END         0x64 /* Termination code for end of packet */

/* FAS status codes  FIXME: put err strings here too */
#define FAS_PENDING		-1	/* used for sts_state tty status */
#define FAS_OK			0x00
#define FAS_ERR_FAIL		0x80
#define FAS_ERR_MULT_CMD	0x01
#define FAS_ERR_BAD_PARAM	0x02
#define FAS_ERR_NOT_PRESENT	0x03
#define FAS_ERR_PARITY		0x04
#define FAS_ERR_OVERRUN		0x05
#define FAS_ERR_FRAMING		0x06
#define FAS_ERR_UNKNOWN		0x07
#define FAS_ERR_INITD		0x08
#define FAS_ERR_BAD_CMD		0x09
#define FAS_ERR_ABORTED		0x0A
#define FAS_ERR_BREAK		0x0B
#define FAS_ERR_OVERFLOW	0x0C
#define FAS_ERR_MAX		FAS_ERR_OVERFLOW


/* FAS_GLOBAL options */ 
#define GLOBAL_ONE_LUN_MODE (1 << 3) /* Select single-LUN SCSI
                                        interface mode */
#define GLOBAL_DEBUG_MODE   (1 << 2) /* Enables port 0 as special debug port */
#define GLOBAL_IGNORE_RESET (1 << 1) /* Firmware ignores SCSI resets */
#define GLOBAL_LED_BLINK    (1)      /* Enables blinking power LED as
                                        loading indicator (blinks more
                                        slowly during heavy loading) */

/* FAS_SET_MODEM options */
#define MODEM_BIT_SAME	0
#define MODEM_BIT_SET	1
#define MODEM_BIT_UNSET 2

/* FAS_SET_PARAMS options */
#define PARAMS_BITS5		0
#define PARAMS_BITS6		1
#define PARAMS_BITS7		2
#define PARAMS_BITS8		3

#define PARAMS_STOP1		0
#define PARAMS_STOP1HALF	1
#define PARAMS_STOP2		2

#define PARAMS_PARITYNO		0
#define PARAMS_PARITYODD	1
#define PARAMS_PARITYEVEN	2

#define PARAMS_LOOPBACK		(1<<7)
#define PARAMS_STRIPLINE	(0)
#define PARAMS_STRIPNO		(1<<1)
#define PARAMS_STRIP7		(1<<2)
#define PARAMS_RECVENABLE	1

#define PARAMS_BAUD75		0x0
#define PARAMS_BAUD110		0x1
#define PARAMS_BAUD150		0x2
#define PARAMS_BAUD300		0x3
#define PARAMS_BAUD600		0x4
#define PARAMS_BAUD1200		0x5
#define PARAMS_BAUD1800		0x6
#define PARAMS_BAUD2000		0x7
#define PARAMS_BAUD2400		0x8
#define PARAMS_BAUD4800		0x9
#define PARAMS_BAUD9600		0xA
#define PARAMS_BAUD19200	0xB
#define PARAMS_BAUD38400	0xC
#define PARAMS_BAUD57600	0xD
/* FIXME: can we do more baud? */


#endif
