1/* $NetBSD: ppbus_1284.h,v 1.7 2008/04/15 15:02:29 cegger Exp $ */
2
3/*-
4 * Copyright (c) 1997 Nicolas Souchu
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * FreeBSD: src/sys/dev/ppbus/ppb_1284.h,v 1.7 2000/01/14 08:03:14 nsouch Exp
29 *
30 */
31#ifndef __PPBUS_1284_H
32#define __PPBUS_1284_H
33
34#include <sys/device.h>	/* for device_t */
35
36/*
37 * IEEE1284 signals
38 */
39
40/* host driven signals */
41
42#define nHostClk	STROBE
43#define Write		STROBE
44
45#define nHostBusy	AUTOFEED
46#define nHostAck	AUTOFEED
47#define DStrb		AUTOFEED
48
49#define nReveseRequest	nINIT
50
51#define nActive1284	SELECTIN
52#define AStrb		SELECTIN
53
54/* peripheral driven signals */
55
56#define nDataAvail	nFAULT
57#define nPeriphRequest	nFAULT
58
59#define Xflag		SELECT
60
61#define AckDataReq	PERROR
62#define nAckReverse	PERROR
63
64#define nPtrBusy	nBUSY
65#define nPeriphAck	nBUSY
66#define Wait		nBUSY
67
68#define PtrClk		nACK
69#define PeriphClk	nACK
70#define Intr		nACK
71
72/* request mode values */
73#define NIBBLE_1284_NORMAL	0x0
74#define NIBBLE_1284_REQUEST_ID	0x4
75#define BYTE_1284_NORMAL	0x1
76#define BYTE_1284_REQUEST_ID	0x5
77#define ECP_1284_NORMAL		0x10
78#define ECP_1284_REQUEST_ID	0x14
79#define ECP_1284_RLE		0x30
80#define ECP_1284_RLE_REQUEST_ID	0x34
81#define EPP_1284_NORMAL		0x40
82#define EXT_LINK_1284_NORMAL	0x80
83
84/* ieee1284 mode options */
85#define PPBUS_REQUEST_ID		0x1
86#define PPBUS_USE_RLE		0x2
87#define PPBUS_EXTENSIBILITY_LINK	0x4
88
89/* ieee1284 errors */
90#define PPBUS_NO_ERROR		0
91#define PPBUS_MODE_UNSUPPORTED	1	/* mode not supported by peripheral */
92#define PPBUS_NOT_IEEE1284	2	/* not an IEEE1284 compliant periph. */
93#define PPBUS_TIMEOUT		3	/* timeout */
94#define PPBUS_INVALID_MODE	4	/* current mode is incorrect */
95
96/* ieee1284 host side states */
97#define PPBUS_ERROR			0
98#define PPBUS_FORWARD_IDLE		1
99#define PPBUS_NEGOTIATION			2
100#define PPBUS_SETUP			3
101#define PPBUS_ECP_FORWARD_IDLE		4
102#define PPBUS_FWD_TO_REVERSE		5
103#define PPBUS_REVERSE_IDLE		6
104#define PPBUS_REVERSE_TRANSFER		7
105#define PPBUS_REVERSE_TO_FWD		8
106#define PPBUS_EPP_IDLE			9
107#define PPBUS_TERMINATION			10
108
109/* peripheral side states */
110#define PPBUS_PERIPHERAL_NEGOTIATION	11
111#define PPBUS_PERIPHERAL_IDLE		12
112#define PPBUS_PERIPHERAL_TRANSFER		13
113#define PPBUS_PERIPHERAL_TERMINATION	14
114
115/* Function prototypes */
116
117/* Host functions */
118int ppbus_1284_negotiate(device_t, int, int);
119int ppbus_1284_terminate(device_t);
120int ppbus_1284_read_id(device_t, int, char **, size_t *, size_t *);
121int ppbus_1284_get_state(device_t);
122int ppbus_1284_set_state(device_t, int state);
123
124/* Peripheral functions */
125int ppbus_peripheral_terminate(device_t, int);
126int ppbus_peripheral_negotiate(device_t, int, int);
127int byte_peripheral_write(device_t, char *, int, int *);
128
129#endif /* __PPBUS_1284_H */
130