162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * USB ConnectTech WhiteHEAT driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *      Copyright (C) 2002
662306a36Sopenharmony_ci *          Connect Tech Inc.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci *      Copyright (C) 1999, 2000
962306a36Sopenharmony_ci *          Greg Kroah-Hartman (greg@kroah.com)
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * See Documentation/usb/usb-serial.rst for more information on using this
1262306a36Sopenharmony_ci * driver
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#ifndef __LINUX_USB_SERIAL_WHITEHEAT_H
1762306a36Sopenharmony_ci#define __LINUX_USB_SERIAL_WHITEHEAT_H
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* WhiteHEAT commands */
2162306a36Sopenharmony_ci#define WHITEHEAT_OPEN			1	/* open the port */
2262306a36Sopenharmony_ci#define WHITEHEAT_CLOSE			2	/* close the port */
2362306a36Sopenharmony_ci#define WHITEHEAT_SETUP_PORT		3	/* change port settings */
2462306a36Sopenharmony_ci#define WHITEHEAT_SET_RTS		4	/* turn RTS on or off */
2562306a36Sopenharmony_ci#define WHITEHEAT_SET_DTR		5	/* turn DTR on or off */
2662306a36Sopenharmony_ci#define WHITEHEAT_SET_BREAK		6	/* turn BREAK on or off */
2762306a36Sopenharmony_ci#define WHITEHEAT_DUMP			7	/* dump memory */
2862306a36Sopenharmony_ci#define WHITEHEAT_STATUS		8	/* get status */
2962306a36Sopenharmony_ci#define WHITEHEAT_PURGE			9	/* clear the UART fifos */
3062306a36Sopenharmony_ci#define WHITEHEAT_GET_DTR_RTS		10	/* get the state of DTR and RTS
3162306a36Sopenharmony_ci							for a port */
3262306a36Sopenharmony_ci#define WHITEHEAT_GET_HW_INFO		11	/* get EEPROM info and
3362306a36Sopenharmony_ci							hardware ID */
3462306a36Sopenharmony_ci#define WHITEHEAT_REPORT_TX_DONE	12	/* get the next TX done */
3562306a36Sopenharmony_ci#define WHITEHEAT_EVENT			13	/* unsolicited status events */
3662306a36Sopenharmony_ci#define WHITEHEAT_ECHO			14	/* send data to the indicated
3762306a36Sopenharmony_ci						   IN endpoint */
3862306a36Sopenharmony_ci#define WHITEHEAT_DO_TEST		15	/* perform specified test */
3962306a36Sopenharmony_ci#define WHITEHEAT_CMD_COMPLETE		16	/* reply for some commands */
4062306a36Sopenharmony_ci#define WHITEHEAT_CMD_FAILURE		17	/* reply for failed commands */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci/*
4462306a36Sopenharmony_ci * Commands to the firmware
4562306a36Sopenharmony_ci */
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/*
4962306a36Sopenharmony_ci * WHITEHEAT_OPEN
5062306a36Sopenharmony_ci * WHITEHEAT_CLOSE
5162306a36Sopenharmony_ci * WHITEHEAT_STATUS
5262306a36Sopenharmony_ci * WHITEHEAT_GET_DTR_RTS
5362306a36Sopenharmony_ci * WHITEHEAT_REPORT_TX_DONE
5462306a36Sopenharmony_ci*/
5562306a36Sopenharmony_cistruct whiteheat_simple {
5662306a36Sopenharmony_ci	__u8	port;	/* port number (1 to N) */
5762306a36Sopenharmony_ci};
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci/*
6162306a36Sopenharmony_ci * WHITEHEAT_SETUP_PORT
6262306a36Sopenharmony_ci */
6362306a36Sopenharmony_ci#define WHITEHEAT_PAR_NONE	'n'	/* no parity */
6462306a36Sopenharmony_ci#define WHITEHEAT_PAR_EVEN	'e'	/* even parity */
6562306a36Sopenharmony_ci#define WHITEHEAT_PAR_ODD	'o'	/* odd parity */
6662306a36Sopenharmony_ci#define WHITEHEAT_PAR_SPACE	'0'	/* space (force 0) parity */
6762306a36Sopenharmony_ci#define WHITEHEAT_PAR_MARK	'1'	/* mark (force 1) parity */
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define WHITEHEAT_SFLOW_NONE	'n'	/* no software flow control */
7062306a36Sopenharmony_ci#define WHITEHEAT_SFLOW_RX	'r'	/* XOFF/ON is sent when RX
7162306a36Sopenharmony_ci					   fills/empties */
7262306a36Sopenharmony_ci#define WHITEHEAT_SFLOW_TX	't'	/* when received XOFF/ON will
7362306a36Sopenharmony_ci					   stop/start TX */
7462306a36Sopenharmony_ci#define WHITEHEAT_SFLOW_RXTX	'b'	/* both SFLOW_RX and SFLOW_TX */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#define WHITEHEAT_HFLOW_NONE		0x00	/* no hardware flow control */
7762306a36Sopenharmony_ci#define WHITEHEAT_HFLOW_RTS_TOGGLE	0x01	/* RTS is on during transmit,
7862306a36Sopenharmony_ci						   off otherwise */
7962306a36Sopenharmony_ci#define WHITEHEAT_HFLOW_DTR		0x02	/* DTR is off/on when RX
8062306a36Sopenharmony_ci						   fills/empties */
8162306a36Sopenharmony_ci#define WHITEHEAT_HFLOW_CTS		0x08	/* when received CTS off/on
8262306a36Sopenharmony_ci						   will stop/start TX */
8362306a36Sopenharmony_ci#define WHITEHEAT_HFLOW_DSR		0x10	/* when received DSR off/on
8462306a36Sopenharmony_ci						   will stop/start TX */
8562306a36Sopenharmony_ci#define WHITEHEAT_HFLOW_RTS		0x80	/* RTS is off/on when RX
8662306a36Sopenharmony_ci						   fills/empties */
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cistruct whiteheat_port_settings {
8962306a36Sopenharmony_ci	__u8	port;		/* port number (1 to N) */
9062306a36Sopenharmony_ci	__le32	baud;		/* any value 7 - 460800, firmware calculates
9162306a36Sopenharmony_ci				   best fit; arrives little endian */
9262306a36Sopenharmony_ci	__u8	bits;		/* 5, 6, 7, or 8 */
9362306a36Sopenharmony_ci	__u8	stop;		/* 1 or 2, default 1 (2 = 1.5 if bits = 5) */
9462306a36Sopenharmony_ci	__u8	parity;		/* see WHITEHEAT_PAR_* above */
9562306a36Sopenharmony_ci	__u8	sflow;		/* see WHITEHEAT_SFLOW_* above */
9662306a36Sopenharmony_ci	__u8	xoff;		/* XOFF byte value */
9762306a36Sopenharmony_ci	__u8	xon;		/* XON byte value */
9862306a36Sopenharmony_ci	__u8	hflow;		/* see WHITEHEAT_HFLOW_* above */
9962306a36Sopenharmony_ci	__u8	lloop;		/* 0/1 turns local loopback mode off/on */
10062306a36Sopenharmony_ci} __attribute__ ((packed));
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci/*
10462306a36Sopenharmony_ci * WHITEHEAT_SET_RTS
10562306a36Sopenharmony_ci * WHITEHEAT_SET_DTR
10662306a36Sopenharmony_ci * WHITEHEAT_SET_BREAK
10762306a36Sopenharmony_ci */
10862306a36Sopenharmony_ci#define WHITEHEAT_RTS_OFF	0x00
10962306a36Sopenharmony_ci#define WHITEHEAT_RTS_ON	0x01
11062306a36Sopenharmony_ci#define WHITEHEAT_DTR_OFF	0x00
11162306a36Sopenharmony_ci#define WHITEHEAT_DTR_ON	0x01
11262306a36Sopenharmony_ci#define WHITEHEAT_BREAK_OFF	0x00
11362306a36Sopenharmony_ci#define WHITEHEAT_BREAK_ON	0x01
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_cistruct whiteheat_set_rdb {
11662306a36Sopenharmony_ci	__u8	port;		/* port number (1 to N) */
11762306a36Sopenharmony_ci	__u8	state;		/* 0/1 turns signal off/on */
11862306a36Sopenharmony_ci};
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci/*
12262306a36Sopenharmony_ci * WHITEHEAT_DUMP
12362306a36Sopenharmony_ci */
12462306a36Sopenharmony_ci#define WHITEHEAT_DUMP_MEM_DATA		'd'  /* data */
12562306a36Sopenharmony_ci#define WHITEHEAT_DUMP_MEM_IDATA	'i'  /* idata */
12662306a36Sopenharmony_ci#define WHITEHEAT_DUMP_MEM_BDATA	'b'  /* bdata */
12762306a36Sopenharmony_ci#define WHITEHEAT_DUMP_MEM_XDATA	'x'  /* xdata */
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci/*
13062306a36Sopenharmony_ci * Allowable address ranges (firmware checks address):
13162306a36Sopenharmony_ci * Type DATA:  0x00 - 0xff
13262306a36Sopenharmony_ci * Type IDATA: 0x80 - 0xff
13362306a36Sopenharmony_ci * Type BDATA: 0x20 - 0x2f
13462306a36Sopenharmony_ci * Type XDATA: 0x0000 - 0xffff
13562306a36Sopenharmony_ci *
13662306a36Sopenharmony_ci * B/I/DATA all read the local memory space
13762306a36Sopenharmony_ci * XDATA reads the external memory space
13862306a36Sopenharmony_ci * BDATA returns bits as bytes
13962306a36Sopenharmony_ci *
14062306a36Sopenharmony_ci * NOTE: 0x80 - 0xff (local space) are the Special Function Registers
14162306a36Sopenharmony_ci *       of the 8051, and some have on-read side-effects.
14262306a36Sopenharmony_ci */
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_cistruct whiteheat_dump {
14562306a36Sopenharmony_ci	__u8	mem_type;	/* see WHITEHEAT_DUMP_* above */
14662306a36Sopenharmony_ci	__u16	addr;		/* address, see restrictions above */
14762306a36Sopenharmony_ci	__u16	length;		/* number of bytes to dump, max 63 bytes */
14862306a36Sopenharmony_ci};
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/*
15262306a36Sopenharmony_ci * WHITEHEAT_PURGE
15362306a36Sopenharmony_ci */
15462306a36Sopenharmony_ci#define WHITEHEAT_PURGE_RX	0x01	/* purge rx fifos */
15562306a36Sopenharmony_ci#define WHITEHEAT_PURGE_TX	0x02	/* purge tx fifos */
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_cistruct whiteheat_purge {
15862306a36Sopenharmony_ci	__u8	port;		/* port number (1 to N) */
15962306a36Sopenharmony_ci	__u8	what;		/* bit pattern of what to purge */
16062306a36Sopenharmony_ci};
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci/*
16462306a36Sopenharmony_ci * WHITEHEAT_ECHO
16562306a36Sopenharmony_ci */
16662306a36Sopenharmony_cistruct whiteheat_echo {
16762306a36Sopenharmony_ci	__u8	port;		/* port number (1 to N) */
16862306a36Sopenharmony_ci	__u8	length;		/* length of message to echo, max 61 bytes */
16962306a36Sopenharmony_ci	__u8	echo_data[61];	/* data to echo */
17062306a36Sopenharmony_ci};
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci/*
17462306a36Sopenharmony_ci * WHITEHEAT_DO_TEST
17562306a36Sopenharmony_ci */
17662306a36Sopenharmony_ci#define WHITEHEAT_TEST_UART_RW		0x01  /* read/write uart registers */
17762306a36Sopenharmony_ci#define WHITEHEAT_TEST_UART_INTR	0x02  /* uart interrupt */
17862306a36Sopenharmony_ci#define WHITEHEAT_TEST_SETUP_CONT	0x03  /* setup for
17962306a36Sopenharmony_ci						PORT_CONT/PORT_DISCONT */
18062306a36Sopenharmony_ci#define WHITEHEAT_TEST_PORT_CONT	0x04  /* port connect */
18162306a36Sopenharmony_ci#define WHITEHEAT_TEST_PORT_DISCONT	0x05  /* port disconnect */
18262306a36Sopenharmony_ci#define WHITEHEAT_TEST_UART_CLK_START	0x06  /* uart clock test start */
18362306a36Sopenharmony_ci#define WHITEHEAT_TEST_UART_CLK_STOP	0x07  /* uart clock test stop */
18462306a36Sopenharmony_ci#define WHITEHEAT_TEST_MODEM_FT		0x08  /* modem signals, requires a
18562306a36Sopenharmony_ci						loopback cable/connector */
18662306a36Sopenharmony_ci#define WHITEHEAT_TEST_ERASE_EEPROM	0x09  /* erase eeprom */
18762306a36Sopenharmony_ci#define WHITEHEAT_TEST_READ_EEPROM	0x0a  /* read eeprom */
18862306a36Sopenharmony_ci#define WHITEHEAT_TEST_PROGRAM_EEPROM	0x0b  /* program eeprom */
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_cistruct whiteheat_test {
19162306a36Sopenharmony_ci	__u8	port;		/* port number (1 to n) */
19262306a36Sopenharmony_ci	__u8	test;		/* see WHITEHEAT_TEST_* above*/
19362306a36Sopenharmony_ci	__u8	info[32];	/* additional info */
19462306a36Sopenharmony_ci};
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci/*
19862306a36Sopenharmony_ci * Replies from the firmware
19962306a36Sopenharmony_ci */
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci/*
20362306a36Sopenharmony_ci * WHITEHEAT_STATUS
20462306a36Sopenharmony_ci */
20562306a36Sopenharmony_ci#define WHITEHEAT_EVENT_MODEM		0x01	/* modem field is valid */
20662306a36Sopenharmony_ci#define WHITEHEAT_EVENT_ERROR		0x02	/* error field is valid */
20762306a36Sopenharmony_ci#define WHITEHEAT_EVENT_FLOW		0x04	/* flow field is valid */
20862306a36Sopenharmony_ci#define WHITEHEAT_EVENT_CONNECT		0x08	/* connect field is valid */
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define WHITEHEAT_FLOW_NONE		0x00	/* no flow control active */
21162306a36Sopenharmony_ci#define WHITEHEAT_FLOW_HARD_OUT		0x01	/* TX is stopped by CTS
21262306a36Sopenharmony_ci						  (waiting for CTS to go on) */
21362306a36Sopenharmony_ci#define WHITEHEAT_FLOW_HARD_IN		0x02	/* remote TX is stopped
21462306a36Sopenharmony_ci						  by RTS */
21562306a36Sopenharmony_ci#define WHITEHEAT_FLOW_SOFT_OUT		0x04	/* TX is stopped by XOFF
21662306a36Sopenharmony_ci						  received (waiting for XON) */
21762306a36Sopenharmony_ci#define WHITEHEAT_FLOW_SOFT_IN		0x08	/* remote TX is stopped by XOFF
21862306a36Sopenharmony_ci						  transmitted */
21962306a36Sopenharmony_ci#define WHITEHEAT_FLOW_TX_DONE		0x80	/* TX has completed */
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_cistruct whiteheat_status_info {
22262306a36Sopenharmony_ci	__u8	port;		/* port number (1 to N) */
22362306a36Sopenharmony_ci	__u8	event;		/* indicates what the current event is,
22462306a36Sopenharmony_ci					see WHITEHEAT_EVENT_* above */
22562306a36Sopenharmony_ci	__u8	modem;		/* modem signal status (copy of uart's
22662306a36Sopenharmony_ci					MSR register) */
22762306a36Sopenharmony_ci	__u8	error;		/* line status (copy of uart's LSR register) */
22862306a36Sopenharmony_ci	__u8	flow;		/* flow control state, see WHITEHEAT_FLOW_*
22962306a36Sopenharmony_ci					above */
23062306a36Sopenharmony_ci	__u8	connect;	/* 0 means not connected, non-zero means
23162306a36Sopenharmony_ci					connected */
23262306a36Sopenharmony_ci};
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci/*
23662306a36Sopenharmony_ci * WHITEHEAT_GET_DTR_RTS
23762306a36Sopenharmony_ci */
23862306a36Sopenharmony_cistruct whiteheat_dr_info {
23962306a36Sopenharmony_ci	__u8	mcr;		/* copy of uart's MCR register */
24062306a36Sopenharmony_ci};
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/*
24462306a36Sopenharmony_ci * WHITEHEAT_GET_HW_INFO
24562306a36Sopenharmony_ci */
24662306a36Sopenharmony_cistruct whiteheat_hw_info {
24762306a36Sopenharmony_ci	__u8	hw_id;		/* hardware id number, WhiteHEAT = 0 */
24862306a36Sopenharmony_ci	__u8	sw_major_rev;	/* major version number */
24962306a36Sopenharmony_ci	__u8	sw_minor_rev;	/* minor version number */
25062306a36Sopenharmony_ci	struct whiteheat_hw_eeprom_info {
25162306a36Sopenharmony_ci		__u8	b0;			/* B0 */
25262306a36Sopenharmony_ci		__u8	vendor_id_low;		/* vendor id (low byte) */
25362306a36Sopenharmony_ci		__u8	vendor_id_high;		/* vendor id (high byte) */
25462306a36Sopenharmony_ci		__u8	product_id_low;		/* product id (low byte) */
25562306a36Sopenharmony_ci		__u8	product_id_high;	/* product id (high byte) */
25662306a36Sopenharmony_ci		__u8	device_id_low;		/* device id (low byte) */
25762306a36Sopenharmony_ci		__u8	device_id_high;		/* device id (high byte) */
25862306a36Sopenharmony_ci		__u8	not_used_1;
25962306a36Sopenharmony_ci		__u8	serial_number_0;	/* serial number (low byte) */
26062306a36Sopenharmony_ci		__u8	serial_number_1;	/* serial number */
26162306a36Sopenharmony_ci		__u8	serial_number_2;	/* serial number */
26262306a36Sopenharmony_ci		__u8	serial_number_3;	/* serial number (high byte) */
26362306a36Sopenharmony_ci		__u8	not_used_2;
26462306a36Sopenharmony_ci		__u8	not_used_3;
26562306a36Sopenharmony_ci		__u8	checksum_low;		/* checksum (low byte) */
26662306a36Sopenharmony_ci		__u8	checksum_high;		/* checksum (high byte */
26762306a36Sopenharmony_ci	} hw_eeprom_info;	/* EEPROM contents */
26862306a36Sopenharmony_ci};
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci/*
27262306a36Sopenharmony_ci * WHITEHEAT_EVENT
27362306a36Sopenharmony_ci */
27462306a36Sopenharmony_cistruct whiteheat_event_info {
27562306a36Sopenharmony_ci	__u8	port;		/* port number (1 to N) */
27662306a36Sopenharmony_ci	__u8	event;		/* see whiteheat_status_info.event */
27762306a36Sopenharmony_ci	__u8	info;		/* see whiteheat_status_info.modem, .error,
27862306a36Sopenharmony_ci					.flow, .connect */
27962306a36Sopenharmony_ci};
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci/*
28362306a36Sopenharmony_ci * WHITEHEAT_DO_TEST
28462306a36Sopenharmony_ci */
28562306a36Sopenharmony_ci#define WHITEHEAT_TEST_FAIL	0x00  /* test failed */
28662306a36Sopenharmony_ci#define WHITEHEAT_TEST_UNKNOWN	0x01  /* unknown test requested */
28762306a36Sopenharmony_ci#define WHITEHEAT_TEST_PASS	0xff  /* test passed */
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_cistruct whiteheat_test_info {
29062306a36Sopenharmony_ci	__u8	port;		/* port number (1 to N) */
29162306a36Sopenharmony_ci	__u8	test;		/* indicates which test this is a response for,
29262306a36Sopenharmony_ci				   see WHITEHEAT_DO_TEST above */
29362306a36Sopenharmony_ci	__u8	status;		/* see WHITEHEAT_TEST_* above */
29462306a36Sopenharmony_ci	__u8	results[32];	/* test-dependent results */
29562306a36Sopenharmony_ci};
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci#endif
299