128257Smsmith/*-
228257Smsmith * Copyright (c) 1997 Nicolas Souchu
328257Smsmith * All rights reserved.
428257Smsmith *
528257Smsmith * Redistribution and use in source and binary forms, with or without
628257Smsmith * modification, are permitted provided that the following conditions
728257Smsmith * are met:
828257Smsmith * 1. Redistributions of source code must retain the above copyright
928257Smsmith *    notice, this list of conditions and the following disclaimer.
1028257Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1128257Smsmith *    notice, this list of conditions and the following disclaimer in the
1228257Smsmith *    documentation and/or other materials provided with the distribution.
1328257Smsmith *
1428257Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1528257Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1628257Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1728257Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1828257Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1928257Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2028257Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2128257Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2228257Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2328257Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2428257Smsmith * SUCH DAMAGE.
2528257Smsmith *
2650477Speter * $FreeBSD$
2728257Smsmith *
2828257Smsmith */
2928257Smsmith#ifndef __1284_H
3028257Smsmith#define __1284_H
3128257Smsmith
3239134Snsouch/*
3339134Snsouch * IEEE1284 signals
3439134Snsouch */
3539134Snsouch
3639134Snsouch/* host driven signals */
3739134Snsouch
3839134Snsouch#define nHostClk	STROBE
3939134Snsouch#define Write		STROBE
4039134Snsouch
4139134Snsouch#define nHostBusy	AUTOFEED
4239134Snsouch#define nHostAck	AUTOFEED
4339134Snsouch#define DStrb		AUTOFEED
4439134Snsouch
4539134Snsouch#define nReveseRequest	nINIT
4639134Snsouch
4739134Snsouch#define nActive1284	SELECTIN
4839134Snsouch#define AStrb		SELECTIN
4939134Snsouch
5039134Snsouch/* peripheral driven signals */
5139134Snsouch
5239134Snsouch#define nDataAvail	nFAULT
5339134Snsouch#define nPeriphRequest	nFAULT
5439134Snsouch
5539134Snsouch#define Xflag		SELECT
5639134Snsouch
5739134Snsouch#define AckDataReq	PERROR
5839134Snsouch#define nAckReverse	PERROR
5939134Snsouch
6039134Snsouch#define nPtrBusy	nBUSY
6139134Snsouch#define nPeriphAck	nBUSY
6239134Snsouch#define Wait		nBUSY
6339134Snsouch
6439134Snsouch#define PtrClk		nACK
6539134Snsouch#define PeriphClk	nACK
6639134Snsouch#define Intr		nACK
6739134Snsouch
6839134Snsouch/* request mode values */
6942475Snsouch#define NIBBLE_1284_NORMAL	0x0
7042475Snsouch#define NIBBLE_1284_REQUEST_ID	0x4
7142475Snsouch#define BYTE_1284_NORMAL	0x1
7242475Snsouch#define BYTE_1284_REQUEST_ID	0x5
7342475Snsouch#define ECP_1284_NORMAL		0x10
7442475Snsouch#define ECP_1284_REQUEST_ID	0x14
7542475Snsouch#define ECP_1284_RLE		0x30
7642475Snsouch#define ECP_1284_RLE_REQUEST_ID	0x34
7742475Snsouch#define EPP_1284_NORMAL		0x40
7842475Snsouch#define EXT_LINK_1284_NORMAL	0x80
7928257Smsmith
8042475Snsouch/* ieee1284 mode options */
8142475Snsouch#define PPB_REQUEST_ID		0x1
8242475Snsouch#define PPB_USE_RLE		0x2
8342475Snsouch#define PPB_EXTENSIBILITY_LINK	0x4
8439134Snsouch
8542475Snsouch/* ieee1284 errors */
8642475Snsouch#define PPB_NO_ERROR		0
8742475Snsouch#define PPB_MODE_UNSUPPORTED	1	/* mode not supported by peripheral */
8842475Snsouch#define PPB_NOT_IEEE1284	2	/* not an IEEE1284 compliant periph. */
8942475Snsouch#define PPB_TIMEOUT		3	/* timeout */
9042475Snsouch#define PPB_INVALID_MODE	4	/* current mode is incorrect */
9138061Smsmith
9242475Snsouch/* ieee1284 host side states */
9342475Snsouch#define PPB_ERROR			0
9442475Snsouch#define PPB_FORWARD_IDLE		1
9542475Snsouch#define PPB_NEGOCIATION			2
9642475Snsouch#define PPB_SETUP			3
9742475Snsouch#define PPB_ECP_FORWARD_IDLE		4
9842475Snsouch#define PPB_FWD_TO_REVERSE		5
9942475Snsouch#define PPB_REVERSE_IDLE		6
10042475Snsouch#define PPB_REVERSE_TRANSFER		7
10142475Snsouch#define PPB_REVERSE_TO_FWD		8
10242475Snsouch#define PPB_EPP_IDLE			9
10342475Snsouch#define PPB_TERMINATION			10
10442475Snsouch
10542475Snsouch/* peripheral side states */
10642475Snsouch#define PPB_PERIPHERAL_NEGOCIATION	11
10742475Snsouch#define PPB_PERIPHERAL_IDLE		12
10842475Snsouch#define PPB_PERIPHERAL_TRANSFER		13
10942475Snsouch#define PPB_PERIPHERAL_TERMINATION	14
11042475Snsouch
11155939Snsouchextern int nibble_1284_inbyte(device_t, char *);
11255939Snsouchextern int byte_1284_inbyte(device_t, char *);
11355939Snsouchextern int spp_1284_read(device_t, int, char *, int, int *);
11428257Smsmith
11555939Snsouchextern int ppb_1284_negociate(device_t, int, int);
11655939Snsouchextern int ppb_1284_terminate(device_t);
11755939Snsouchextern int ppb_1284_read_id(device_t, int, char *, int, int *);
11855939Snsouchextern int ppb_1284_read(device_t, int, char *, int, int *);
11955957Snsouchextern int ppb_1284_get_state(device_t bus);
12055957Snsouchextern int ppb_1284_set_state(device_t bus, int state);
12139134Snsouch
12255939Snsouchextern int ppb_peripheral_terminate(device_t, int);
12355939Snsouchextern int ppb_peripheral_negociate(device_t, int, int);
12455939Snsouchextern int byte_peripheral_write(device_t, char *, int, int *);
12542475Snsouch
12628257Smsmith#endif
127