| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
| 2 | |
| 3 | /*************************************************************************** |
| 4 | * copyright		 : (C) 2002 by Frank Mori Hess |
| 5 | ***************************************************************************/ |
| 6 | |
| 7 | #ifndef _GPIB_H |
| 8 | #define _GPIB_H |
| 9 | |
| 10 | #define GPIB_MAX_NUM_BOARDS 16 |
| 11 | #define GPIB_MAX_NUM_DESCRIPTORS 0x1000 |
| 12 | |
| 13 | enum ibsta_bit_numbers { |
| 14 | 	DCAS_NUM = 0, |
| 15 | 	DTAS_NUM = 1, |
| 16 | 	LACS_NUM = 2, |
| 17 | 	TACS_NUM = 3, |
| 18 | 	ATN_NUM = 4, |
| 19 | 	CIC_NUM = 5, |
| 20 | 	REM_NUM = 6, |
| 21 | 	LOK_NUM = 7, |
| 22 | 	CMPL_NUM = 8, |
| 23 | 	EVENT_NUM = 9, |
| 24 | 	SPOLL_NUM = 10, |
| 25 | 	RQS_NUM = 11, |
| 26 | 	SRQI_NUM = 12, |
| 27 | 	END_NUM = 13, |
| 28 | 	TIMO_NUM = 14, |
| 29 | 	ERR_NUM = 15 |
| 30 | }; |
| 31 | |
| 32 | /* IBSTA status bits (returned by all functions) */ |
| 33 | enum ibsta_bits { |
| 34 | 	DCAS = (1 << DCAS_NUM),	/* device clear state */ |
| 35 | 	DTAS = (1 << DTAS_NUM),	/* device trigger state */ |
| 36 | 	LACS = (1 << LACS_NUM),	/* GPIB interface is addressed as Listener */ |
| 37 | 	TACS = (1 << TACS_NUM),	/* GPIB interface is addressed as Talker */ |
| 38 | 	ATN = (1 << ATN_NUM),	/* Attention is asserted */ |
| 39 | 	CIC = (1 << CIC_NUM),	/* GPIB interface is Controller-in-Charge */ |
| 40 | 	REM = (1 << REM_NUM),	/* remote state */ |
| 41 | 	LOK = (1 << LOK_NUM),	/* lockout state */ |
| 42 | 	CMPL = (1 << CMPL_NUM),	/* I/O is complete */ |
| 43 | 	EVENT = (1 << EVENT_NUM),	/* DCAS, DTAS, or IFC has occurred */ |
| 44 | 	SPOLL = (1 << SPOLL_NUM),	/* board serial polled by busmaster */ |
| 45 | 	RQS = (1 << RQS_NUM),	/* Device requesting service */ |
| 46 | 	SRQI = (1 << SRQI_NUM),	/* SRQ is asserted */ |
| 47 | 	END = (1 << END_NUM),	/* EOI or EOS encountered */ |
| 48 | 	TIMO = (1 << TIMO_NUM),	/* Time limit on I/O or wait function exceeded */ |
| 49 | 	ERR = (1 << ERR_NUM),	/* Function call terminated on error */ |
| 50 | |
| 51 | 	device_status_mask = ERR | TIMO | END | CMPL | RQS, |
| 52 | 	board_status_mask = ERR | TIMO | END | CMPL | SPOLL | |
| 53 | 		EVENT | LOK | REM | CIC | ATN | TACS | LACS | DTAS | DCAS | SRQI, |
| 54 | }; |
| 55 | |
| 56 | /* End-of-string (EOS) modes for use with ibeos */ |
| 57 | |
| 58 | enum eos_flags { |
| 59 | 	EOS_MASK = 0x1c00, |
| 60 | 	REOS = 0x0400,		/* Terminate reads on EOS	*/ |
| 61 | 	XEOS = 0x800,	/* assert EOI when EOS char is sent */ |
| 62 | 	BIN = 0x1000		/* Do 8-bit compare on EOS	*/ |
| 63 | }; |
| 64 | |
| 65 | /* GPIB Bus Control Lines bit vector */ |
| 66 | enum bus_control_line { |
| 67 | 	VALID_DAV = 0x01, |
| 68 | 	VALID_NDAC = 0x02, |
| 69 | 	VALID_NRFD = 0x04, |
| 70 | 	VALID_IFC = 0x08, |
| 71 | 	VALID_REN = 0x10, |
| 72 | 	VALID_SRQ = 0x20, |
| 73 | 	VALID_ATN = 0x40, |
| 74 | 	VALID_EOI = 0x80, |
| 75 | 	VALID_ALL = 0xff, |
| 76 | 	BUS_DAV = 0x0100,		/* DAV	line status bit */ |
| 77 | 	BUS_NDAC = 0x0200,		/* NDAC line status bit */ |
| 78 | 	BUS_NRFD = 0x0400,		/* NRFD line status bit */ |
| 79 | 	BUS_IFC = 0x0800,		/* IFC	line status bit */ |
| 80 | 	BUS_REN = 0x1000,		/* REN	line status bit */ |
| 81 | 	BUS_SRQ = 0x2000,		/* SRQ	line status bit */ |
| 82 | 	BUS_ATN = 0x4000,		/* ATN	line status bit */ |
| 83 | 	BUS_EOI = 0x8000		/* EOI	line status bit */ |
| 84 | }; |
| 85 | |
| 86 | enum ppe_bits { |
| 87 | 	PPC_DISABLE = 0x10, |
| 88 | 	PPC_SENSE = 0x8,	/* parallel poll sense bit	*/ |
| 89 | 	PPC_DIO_MASK = 0x7 |
| 90 | }; |
| 91 | |
| 92 | enum { |
| 93 | 	request_service_bit = 0x40, |
| 94 | }; |
| 95 | |
| 96 | enum gpib_events { |
| 97 | 	EVENT_NONE = 0, |
| 98 | 	EVENT_DEV_TRG = 1, |
| 99 | 	EVENT_DEV_CLR = 2, |
| 100 | 	EVENT_IFC = 3 |
| 101 | }; |
| 102 | |
| 103 | #endif	/* _GPIB_H */ |